STM32F103C8T6 USB HID

General discussion on mikroPascal PRO for ARM.
Author
Message
LJStefan
Posts: 90
Joined: 17 Feb 2006 16:47
Location: Austria

STM32F103C8T6 USB HID

#1 Post by LJStefan » 19 Apr 2014 11:02

Hi,

I have some troubles to activate the HID on STM32F103C8T6 board.
Thats my test program:

Code: Select all

program MyProject;

{ Declarations section }
var cnt, nread : byte;

var readbuff : array[64] of byte;
var writebuff : array[64] of byte;
counter : dword;

begin
  GPIO_Digital_Output(@GPIOb_BASE, _GPIO_PINMASK_0);
  GPIO_Digital_Output(@GPIOb_BASE, _GPIO_PINMASK_1);
  GPIOb_ODR.b0 := 0; // LED1
  GPIOb_ODR.b1 := 0; // LED2
  counter := 0;
  GPIOb_ODR.b0 := 1;
  HID_Enable(@readbuff,@writebuff);
  
  while TRUE do
    begin
      GPIOb_ODR.b1 := 1;
      USB_Polling_Proc();
      nread := HID_Read();
      GPIOb_ODR.b1 := 0;
      if (nread <> 0) then
      begin
        for cnt:=0 to 63 do
          writebuff[cnt]:=readbuff[cnt];
        HID_Write(@writebuff,64);
      end ;
      counter := counter +1;
      GPIOb_ODR.b0 := counter.b16;
    end;
end.
Windows7 will not detect the HID-Device.
The program stopps allways at USB_Polling_Proc(); or HID_Read();
I would like to init the USB Module with GPIO_Alternate_Function_Enable but i can not find the correct module in the list.

My project settings:

<?xml version="1.0"?>
<MCU_DEVICE_FLAGS>
<DEVICE>
<DEVICE_NAME>STM32F103C8</DEVICE_NAME>
<SETTINGS>
<COUNT>15</COUNT>
<SETTING0>
<NAME>Internal high-speed clock enable</NAME>
<DESCRIPTION>internal 8 MHz RC oscillator ON</DESCRIPTION>
</SETTING0>
<SETTING1>
<NAME>External high-speed clock enable</NAME>
<DESCRIPTION>HSE oscillator OFF</DESCRIPTION>
</SETTING1>
<SETTING2>
<NAME>External high-speed clock bypass</NAME>
<DESCRIPTION>HSE oscillator not bypassed</DESCRIPTION>
</SETTING2>
<SETTING3>
<NAME>Clock security system enable</NAME>
<DESCRIPTION>Clock detector OFF</DESCRIPTION>
</SETTING3>
<SETTING4>
<NAME>PLL enable</NAME>
<DESCRIPTION>PLL ON</DESCRIPTION>
</SETTING4>
<SETTING5>
<NAME>System clock Switch</NAME>
<DESCRIPTION>PLL selected as system clock</DESCRIPTION>
</SETTING5>
<SETTING6>
<NAME>Set and cleared by software to control the division factor of the AHB clock</NAME>
<DESCRIPTION>SYSCLK not divided</DESCRIPTION>
</SETTING6>
<SETTING7>
<NAME>APB low-speed prescaler (APB1)</NAME>
<DESCRIPTION>HCLK not divided </DESCRIPTION>
</SETTING7>
<SETTING8>
<NAME>APB high-speed prescaler (APB2)</NAME>
<DESCRIPTION>HCLK not divided </DESCRIPTION>
</SETTING8>
<SETTING9>
<NAME>ADC prescaler</NAME>
<DESCRIPTION>PCLK2 divided by 2 </DESCRIPTION>
</SETTING9>
<SETTING10>
<NAME>PLL entry clock source</NAME>
<DESCRIPTION>HSI oscillator clock / 2 selected as PLL input clock</DESCRIPTION>
</SETTING10>
<SETTING11>
<NAME>HSE divider for PLL entry</NAME>
<DESCRIPTION>HSE clock not divided</DESCRIPTION>
</SETTING11>
<SETTING12>
<NAME>PLL multiplication factor</NAME>
<DESCRIPTION>PLL input clock x 16</DESCRIPTION>
</SETTING12>
<SETTING13>
<NAME>USB prescaler</NAME>
<DESCRIPTION>PLL clock is not divided</DESCRIPTION>
</SETTING13>
<SETTING14>
<NAME>Microcontroller clock output</NAME>
<DESCRIPTION>No clock</DESCRIPTION>
</SETTING14>
</SETTINGS>
</DEVICE>
</MCU_DEVICE_FLAGS>

Have somebody tried this with the same CPU?
Thanks in advance for any answers.
Best regards
Stefan

User avatar
petar.timotijevic
mikroElektronika team
Posts: 1739
Joined: 19 Feb 2014 13:46
Location: Serbia
Contact:

Re: STM32F103C8T6 USB HID

#2 Post by petar.timotijevic » 22 Apr 2014 13:12

Hi Stefan,

How you set project settings and oscillator?


Best regards,
Peter

LJStefan
Posts: 90
Joined: 17 Feb 2006 16:47
Location: Austria

Re: STM32F103C8T6 USB HID

#3 Post by LJStefan » 22 Apr 2014 22:27

Hello Petar,

I have tried some different settings.
But at the end (and from other threads) i think 48mhz with PLL and no divider for USB must be working.
8/2 = 4 *12 = 48

1.JPG
1.JPG (87.37 KiB) Viewed 16461 times
2.JPG
2.JPG (87.32 KiB) Viewed 16461 times
USBDP is connected with a 22 ohm resitor in series to D+
USBDM is connected with a 22 ohm resitor in series to D-
USBDP has a 10k pullup resistor to 3.3V

Best regards,
Stefan

Pelikan
Posts: 219
Joined: 22 Nov 2012 07:58

Re: STM32F103C8T6 USB HID

#4 Post by Pelikan » 15 Dec 2014 10:38

Hi Stefan,

did you already have a solution?
Or you have to write it myself?

With Greeting
Peter

LJStefan
Posts: 90
Joined: 17 Feb 2006 16:47
Location: Austria

Re: STM32F103C8T6 USB HID

#5 Post by LJStefan » 08 Feb 2015 10:02

Hi Peter,

Sorry for my late reply...
No, i have no solution found for this problem.
I think ME supports only integrated USB Full-Speed modules.
But on the STM32F103 is only a USB High-Speed module integerated and there are many different registers to Full-Speed.

Did you find any solution for this?

Best regards,
Stefan

Pelikan
Posts: 219
Joined: 22 Nov 2012 07:58

Re: STM32F103C8T6 USB HID

#6 Post by Pelikan » 09 Feb 2015 07:52

Hi Stefan

I'm going to find a solution.
Enclosed before a test ( XTAL= 8MHz ).
The HID_STM32F103C8.hex file to load into the MC, so that the STM103C8 is already recognized as a HID device.
More work not yet time.

With Greeting
Peter
Attachments
HID_STM32F103C8.zip
(5.15 KiB) Downloaded 447 times

User avatar
darko.minic
Posts: 747
Joined: 01 Dec 2014 11:10

Re: STM32F103C8T6 USB HID

#7 Post by darko.minic » 09 Feb 2015 14:35

Hello Stefan and Peter,

I tried USB HID example with my STM32F103VG. With some project settings adjustment
STM32F103VG is recognized as HID Device.
You can find example in attachment.

Regards,
Darko
Attachments
HID_Read_Write_Polling.zip
(184.12 KiB) Downloaded 661 times

Pelikan
Posts: 219
Joined: 22 Nov 2012 07:58

Re: STM32F103C8T6 USB HID

#8 Post by Pelikan » 09 Feb 2015 15:32

Hi Darko,

which LIB is to compile?

With Greeting
Peter

User avatar
darko.minic
Posts: 747
Joined: 01 Dec 2014 11:10

Re: STM32F103C8T6 USB HID

#9 Post by darko.minic » 09 Feb 2015 17:07

Hello Peter,

USB library from compiler is used in the project.

Regards,
Darko

Pelikan
Posts: 219
Joined: 22 Nov 2012 07:58

Re: STM32F103C8T6 USB HID

#10 Post by Pelikan » 10 Feb 2015 08:30

Hi Darko,

as expected, it does not work.

Regards,
Peter

User avatar
darko.minic
Posts: 747
Joined: 01 Dec 2014 11:10

Re: STM32F103C8T6 USB HID

#11 Post by darko.minic » 10 Feb 2015 10:54

Hello Peter,

Did you tried to change device from STM32F103VG to STM32F103C8?
If that is the case it is necessary to adjust project settings again.

Regards,
Darko

Pelikan
Posts: 219
Joined: 22 Nov 2012 07:58

Re: STM32F103C8T6 USB HID

#12 Post by Pelikan » 11 Feb 2015 08:39

hi Darko,

this does not work. I'm doing no more experiments.

Please take the mikroProg as a STM32F103C8T6 is installed and which is controlled as a USB HID.

And I want this software as LIB.

with greeting
Peter

User avatar
darko.minic
Posts: 747
Joined: 01 Dec 2014 11:10

Re: STM32F103C8T6 USB HID

#13 Post by darko.minic » 11 Feb 2015 10:09

Hello Peter,

The HID example which I posted here is tested on mine EasyMx Pro v7 with STM32F103VG.
Everything worked as expected, and STM32F103VG was recognized as HID Device in HID terminal.

I can recommend you to try to use project settings from example I posted and try it with your STM32F103C8T6.

Certainly I will forward your suggestion about HID software as LIB for STM32F103C8T6 to Software Department.

Regards,
Darko

TurboProgger
Posts: 66
Joined: 04 Oct 2008 18:39
Location: Germany

Re: STM32F103C8T6 USB HID

#14 Post by TurboProgger » 15 Feb 2015 14:25

@LJStefan

> USBDP is connected with a 22 ohm resitor in series to D+
> USBDM is connected with a 22 ohm resitor in series to D-
> USBDP has a 10k pullup resistor to 3.3V


The resistor value does not fit to the USB specs.

Recommended value is 1K5 (or 1,5K Ohm) for the pullup.

Greetz

serg1980
Posts: 44
Joined: 19 Mar 2014 05:58

Re: STM32F103C8T6 USB HID

#15 Post by serg1980 » 22 Feb 2017 21:57

darko.minic wrote:Hello Peter,

The HID example which I posted here is tested on mine EasyMx Pro v7 with STM32F103VG.
Everything worked as expected, and STM32F103VG was recognized as HID Device in HID terminal.

I can recommend you to try to use project settings from example I posted and try it with your STM32F103C8T6.

Certainly I will forward your suggestion about HID software as LIB for STM32F103C8T6 to Software Department.

Regards,
Darko
Tell me, please, there is a solution of this problem. I can't launch the HID device on stm32f103c8. Win 7 doesn't define it

Post Reply

Return to “mikroPascal PRO for ARM General”