TI中文支持网
TI专业的中文技术问题搜集分享网站

产品急于量产;遇到问题紧急求助!

我用的是TMS320F28069F ;TI例程Motorware中用的是内部RC时钟;用RC时钟做CAN通信时出现不能正常接收;有可能是RC时钟精度问题,现在想改成片载晶振;程序中怎么改?我这样改怎么不行!!!!

void HAL_setupClks(HAL_Handle handle)
{
HAL_Obj *obj = (HAL_Obj *)handle;

// enable internal oscillator 1
CLK_disableOsc1(obj->clkHandle);

// set the oscillator source
CLK_setOscSrc(obj->clkHandle,CLK_OscSrc_External);

// disable the external clock in
CLK_disableClkIn(obj->clkHandle);

// disable the crystal oscillator
CLK_enableCrystalOsc(obj->clkHandle);

// disable oscillator 2
CLK_disableOsc2(obj->clkHandle);
CLK_setOsc2Src(obj->clkHandle,CLK_Osc2Src_Internal);

// set the low speed clock prescaler
CLK_setLowSpdPreScaler(obj->clkHandle,CLK_LowSpdPreScaler_SysClkOut_by_4);

// set the clock out prescaler
CLK_setClkOutPreScaler(obj->clkHandle,CLK_ClkOutPreScaler_SysClkOut_by_1);

return;
} // end of HAL_setupClks() function

mangui zhang:

时钟源选了后   还需要使能

我用的是TMS320F28069F ;TI例程Motorware中用的是内部RC时钟;用RC时钟做CAN通信时出现不能正常接收;有可能是RC时钟精度问题,现在想改成片载晶振;程序中怎么改?我这样改怎么不行!!!!

void HAL_setupClks(HAL_Handle handle)
{
HAL_Obj *obj = (HAL_Obj *)handle;

// enable internal oscillator 1
CLK_disableOsc1(obj->clkHandle);

// set the oscillator source
CLK_setOscSrc(obj->clkHandle,CLK_OscSrc_External);

// disable the external clock in
CLK_disableClkIn(obj->clkHandle);

// disable the crystal oscillator
CLK_enableCrystalOsc(obj->clkHandle);

// disable oscillator 2
CLK_disableOsc2(obj->clkHandle);
CLK_setOsc2Src(obj->clkHandle,CLK_Osc2Src_Internal);

// set the low speed clock prescaler
CLK_setLowSpdPreScaler(obj->clkHandle,CLK_LowSpdPreScaler_SysClkOut_by_4);

// set the clock out prescaler
CLK_setClkOutPreScaler(obj->clkHandle,CLK_ClkOutPreScaler_SysClkOut_by_1);

return;
} // end of HAL_setupClks() function

FOC:

回复 mangui zhang:

哥们。使能在哪选?那段程序给贴出来

我用的是TMS320F28069F ;TI例程Motorware中用的是内部RC时钟;用RC时钟做CAN通信时出现不能正常接收;有可能是RC时钟精度问题,现在想改成片载晶振;程序中怎么改?我这样改怎么不行!!!!

void HAL_setupClks(HAL_Handle handle)
{
HAL_Obj *obj = (HAL_Obj *)handle;

// enable internal oscillator 1
CLK_disableOsc1(obj->clkHandle);

// set the oscillator source
CLK_setOscSrc(obj->clkHandle,CLK_OscSrc_External);

// disable the external clock in
CLK_disableClkIn(obj->clkHandle);

// disable the crystal oscillator
CLK_enableCrystalOsc(obj->clkHandle);

// disable oscillator 2
CLK_disableOsc2(obj->clkHandle);
CLK_setOsc2Src(obj->clkHandle,CLK_Osc2Src_Internal);

// set the low speed clock prescaler
CLK_setLowSpdPreScaler(obj->clkHandle,CLK_LowSpdPreScaler_SysClkOut_by_4);

// set the clock out prescaler
CLK_setClkOutPreScaler(obj->clkHandle,CLK_ClkOutPreScaler_SysClkOut_by_1);

return;
} // end of HAL_setupClks() function

Eric Ma:

回复 FOC:

参考一下代码

CLK_enableCrystalOsc(obj->clkHandle); // Turn on XTALOSCusDelay(1000); // Wait for 1ms while XTAL starts up CLK_setOsc2Src(obj->clkHandle,CLK_Osc2Src_External) CLK_setOscSrc(obj->clkHandle,CLK_OscSrc_External); // disable the external clock in CLK_disableClkIn(obj->clkHandle);

我用的是TMS320F28069F ;TI例程Motorware中用的是内部RC时钟;用RC时钟做CAN通信时出现不能正常接收;有可能是RC时钟精度问题,现在想改成片载晶振;程序中怎么改?我这样改怎么不行!!!!

void HAL_setupClks(HAL_Handle handle)
{
HAL_Obj *obj = (HAL_Obj *)handle;

// enable internal oscillator 1
CLK_disableOsc1(obj->clkHandle);

// set the oscillator source
CLK_setOscSrc(obj->clkHandle,CLK_OscSrc_External);

// disable the external clock in
CLK_disableClkIn(obj->clkHandle);

// disable the crystal oscillator
CLK_enableCrystalOsc(obj->clkHandle);

// disable oscillator 2
CLK_disableOsc2(obj->clkHandle);
CLK_setOsc2Src(obj->clkHandle,CLK_Osc2Src_Internal);

// set the low speed clock prescaler
CLK_setLowSpdPreScaler(obj->clkHandle,CLK_LowSpdPreScaler_SysClkOut_by_4);

// set the clock out prescaler
CLK_setClkOutPreScaler(obj->clkHandle,CLK_ClkOutPreScaler_SysClkOut_by_1);

return;
} // end of HAL_setupClks() function

FOC:

回复 Eric Ma:

void HAL_setupClks(HAL_Handle handle){ HAL_Obj *obj = (HAL_Obj *)handle;

// enable internal oscillator 1 CLK_disableOsc1(obj->clkHandle);

// set the oscillator source CLK_setOscSrc(obj->clkHandle,CLK_OscSrc_External);

// disable the external clock in CLK_disableClkIn(obj->clkHandle);

// disable the crystal oscillator CLK_enableCrystalOsc(obj->clkHandle); usDelay(1000);//

// disable oscillator 2 CLK_disableOsc2(obj->clkHandle);

CLK_setOsc2Src(obj->clkHandle,CLK_Osc2Src_External);

// set the low speed clock prescaler CLK_setLowSpdPreScaler(obj->clkHandle,CLK_LowSpdPreScaler_SysClkOut_by_1);

// set the clock out prescaler CLK_setClkOutPreScaler(obj->clkHandle,CLK_ClkOutPreScaler_SysClkOut_by_1);

return;} // end of HAL_setupClks() function

这样改后试了还是不行!

我用的是TMS320F28069F ;TI例程Motorware中用的是内部RC时钟;用RC时钟做CAN通信时出现不能正常接收;有可能是RC时钟精度问题,现在想改成片载晶振;程序中怎么改?我这样改怎么不行!!!!

void HAL_setupClks(HAL_Handle handle)
{
HAL_Obj *obj = (HAL_Obj *)handle;

// enable internal oscillator 1
CLK_disableOsc1(obj->clkHandle);

// set the oscillator source
CLK_setOscSrc(obj->clkHandle,CLK_OscSrc_External);

// disable the external clock in
CLK_disableClkIn(obj->clkHandle);

// disable the crystal oscillator
CLK_enableCrystalOsc(obj->clkHandle);

// disable oscillator 2
CLK_disableOsc2(obj->clkHandle);
CLK_setOsc2Src(obj->clkHandle,CLK_Osc2Src_Internal);

// set the low speed clock prescaler
CLK_setLowSpdPreScaler(obj->clkHandle,CLK_LowSpdPreScaler_SysClkOut_by_4);

// set the clock out prescaler
CLK_setClkOutPreScaler(obj->clkHandle,CLK_ClkOutPreScaler_SysClkOut_by_1);

return;
} // end of HAL_setupClks() function

Young Hu:

参考下面代码,来改对应的Motorware版本的代码

//—————————————————————————// Example: XtalOscSel://—————————————————————————// This function switches to External CRYSTAL oscillator and turns off all other clock// sources to minimize power consumption. This option may not be available on all// device packages

void XtalOscSel (void) { EALLOW; SysCtrlRegs.CLKCTL.bit.XTALOSCOFF = 0; // Turn on XTALOSC DELAY_US(1000L); // 1mS delay to ensure crystal // oscillator is up and running. // Adjust as needed. SysCtrlRegs.CLKCTL.bit.XCLKINOFF = 1; // Turn off XCLKIN SysCtrlRegs.CLKCTL.bit.OSCCLKSRC2SEL = 0; // Switch to external clock SysCtrlRegs.CLKCTL.bit.OSCCLKSRCSEL = 1; // Switch from INTOSC1 to INTOSC2/ext clk SysCtrlRegs.CLKCTL.bit.WDCLKSRCSEL = 0; //Switch Watchdog Clk Src to internal clock 1 SysCtrlRegs.CLKCTL.bit.INTOSC2OFF = 1; // Turn off INTOSC2 SysCtrlRegs.CLKCTL.bit.INTOSC1OFF = 0; // Turn on INTOSC1 EDIS;

}

我用的是TMS320F28069F ;TI例程Motorware中用的是内部RC时钟;用RC时钟做CAN通信时出现不能正常接收;有可能是RC时钟精度问题,现在想改成片载晶振;程序中怎么改?我这样改怎么不行!!!!

void HAL_setupClks(HAL_Handle handle)
{
HAL_Obj *obj = (HAL_Obj *)handle;

// enable internal oscillator 1
CLK_disableOsc1(obj->clkHandle);

// set the oscillator source
CLK_setOscSrc(obj->clkHandle,CLK_OscSrc_External);

// disable the external clock in
CLK_disableClkIn(obj->clkHandle);

// disable the crystal oscillator
CLK_enableCrystalOsc(obj->clkHandle);

// disable oscillator 2
CLK_disableOsc2(obj->clkHandle);
CLK_setOsc2Src(obj->clkHandle,CLK_Osc2Src_Internal);

// set the low speed clock prescaler
CLK_setLowSpdPreScaler(obj->clkHandle,CLK_LowSpdPreScaler_SysClkOut_by_4);

// set the clock out prescaler
CLK_setClkOutPreScaler(obj->clkHandle,CLK_ClkOutPreScaler_SysClkOut_by_1);

return;
} // end of HAL_setupClks() function

FOC:

回复 Young Hu:

这个我之前参考试过,还是不能运行。我认为别的地方应该还需要改…

我用的是TMS320F28069F ;TI例程Motorware中用的是内部RC时钟;用RC时钟做CAN通信时出现不能正常接收;有可能是RC时钟精度问题,现在想改成片载晶振;程序中怎么改?我这样改怎么不行!!!!

void HAL_setupClks(HAL_Handle handle)
{
HAL_Obj *obj = (HAL_Obj *)handle;

// enable internal oscillator 1
CLK_disableOsc1(obj->clkHandle);

// set the oscillator source
CLK_setOscSrc(obj->clkHandle,CLK_OscSrc_External);

// disable the external clock in
CLK_disableClkIn(obj->clkHandle);

// disable the crystal oscillator
CLK_enableCrystalOsc(obj->clkHandle);

// disable oscillator 2
CLK_disableOsc2(obj->clkHandle);
CLK_setOsc2Src(obj->clkHandle,CLK_Osc2Src_Internal);

// set the low speed clock prescaler
CLK_setLowSpdPreScaler(obj->clkHandle,CLK_LowSpdPreScaler_SysClkOut_by_4);

// set the clock out prescaler
CLK_setClkOutPreScaler(obj->clkHandle,CLK_ClkOutPreScaler_SysClkOut_by_1);

return;
} // end of HAL_setupClks() function

Eric Ma:

回复 FOC:

// disable oscillator 2CLK_disableOsc2(obj->clkHandle);

不要加这句。

另外你外部晶振多少M。

ERIC

赞(0)
未经允许不得转载:TI中文支持网 » 产品急于量产;遇到问题紧急求助!
分享到: 更多 (0)