BSP setting for USB

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 
1,737件の閲覧回数
Teckna
Contributor V

Hi everyone,

 

I'm working on a custom board with CW10, MQX 3.8 and K60N512 processor.

 

With this board I have successfully worked with MQX 3.7. Now that I ported all custom drivers to MQX 3.8, everything is ok except the USB. I cloned the BSP twrk60n512 and I modified the line 58 in the bsp_cm.h file from

#define CPU_XTAL_CLK_HZ                 0x02FAF080U /* Value of the external crystal or oscillator clock frequency in Hz */

to

#define CPU_XTAL_CLK_HZ                 0x016E3600U /* Value of the external crystal or oscillator clock frequency in Hz */

(my external clock is 24 MHz instead of 50 MHz as in the twrk60n512 board)

 

When I insert the USB cable in the PC port the device is not recognized, even if leave the 50 MHz define.

The only way I found to make the USB work is to set the SIM_CLKDIV2.USBDIV field to 0 instead of 1 in the Cpu_SetClockConfiguration function: I modified the line 717 in the bsp_cm.c file from

      SIM_CLKDIV2 = (uint32_t)((SIM_CLKDIV2 & (uint32_t)~0x0DUL) | (uint32_t)0x02UL); /* Update USB clock prescalers */

to

      SIM_CLKDIV2 = (uint32_t)(SIM_CLKDIV2 & (uint32_t)~0x0FUL); /* Update USB clock prescalers */

Am I right or do I have to modifiy other things?

Any other advice?

 

Many thanks

Teckna

0 件の賞賛
返信
1 解決策
1,160件の閲覧回数
Teckna
Contributor V

Solved:

 

I need USBFRAC=0 and USBDIV=1 as for twrk60n512 bsp, but i need to modifiy the values written in the MCG_C5.PRDIV field in the bsp_cm.c file (fclk = 50 MHz => PRDIV = 0x18 resulting in 2 MHz in twrk60n512 bsp, fclk = 24 MHz => PRDIV = 0x0B resulting in same 2 MHz in my custom bsp).

 

In MQX 3.7 this value was set depending on the macro value representing external clock frequency, in MQX is written directly in the code: why this mechanism has been depreceted, while it is so useful?

 

Many thanks

Teckna

元の投稿で解決策を見る

0 件の賞賛
返信
4 返答(返信)
1,160件の閲覧回数
petr_uhlir
NXP Employee
NXP Employee

The easiest way for you when you are using CodeWarrior would be to setup your clock settings using Processor Expert. 

You can follow descriprion in "...Freescale MQX 3.8\doc\tools\cw\Howto_SetupKinetisClock_UsingPE.pdf"

0 件の賞賛
返信
1,160件の閲覧回数
Mohsin455
Contributor IV

Hi,

 

The USB requires 48MHz clock. Hence you need to  USBFRAC=1 and USBDIV=0.

 

Regards,

Mohsin

 

0 件の賞賛
返信
1,161件の閲覧回数
Teckna
Contributor V

Solved:

 

I need USBFRAC=0 and USBDIV=1 as for twrk60n512 bsp, but i need to modifiy the values written in the MCG_C5.PRDIV field in the bsp_cm.c file (fclk = 50 MHz => PRDIV = 0x18 resulting in 2 MHz in twrk60n512 bsp, fclk = 24 MHz => PRDIV = 0x0B resulting in same 2 MHz in my custom bsp).

 

In MQX 3.7 this value was set depending on the macro value representing external clock frequency, in MQX is written directly in the code: why this mechanism has been depreceted, while it is so useful?

 

Many thanks

Teckna

0 件の賞賛
返信
1,160件の閲覧回数
egoodii
Senior Contributor III

Agreed -- Embedding this Processor Expert-generated code into an OS release is 'not friendly', especially with all the embedded hard-constants, for ANY user not tied-in with their CodeWarrior toolset.

0 件の賞賛
返信