I am trying to setup a 20MHz crystal on the X1 and X2 pins of a TMS320F28027F processor. When I ran the Instaspin with the below clock nothing ran correctly and when I tried to reprogram back the original code the JTAG gave me a Flash programming Error. It seems the chip is corrupted now and I may have to replace the processor to get past the flash error. The Error in the console is
C28xx: Flash Programmer: Error encountered when writing to flash memory
I can write to other boards with the original code and all is OK. So, I believe my Flash got corrupted somehow.
The below clock setup code is what done me in I believe. I am afraid to try on another board.
If someone could help me to correctly setup the external crystal to provide the proper clocks for the InstaSpin FOC to work correctly, it would be helpful. Also, do I need to make any changes to the PLL setup or any other setups.
void HAL_setupClks(HAL_Handle handle)
{
HAL_Obj *obj = (HAL_Obj *)handle;
CLK_disableOsc1(obj->clkHandle);
CLK_disableClkIn(obj->clkHandle);
CLK_enableCrystalOsc(obj->clkHandle);
CLK_disableOsc2(obj->clkHandle);
CLK_setOsc2Src(obj->clkHandle,CLK_Osc2Src_Internal);
CLK_setOscSrc(obj->clkHandle,CLK_OscSrc_External);
CLK_setLowSpdPreScaler(obj->clkHandle,CLK_LowSpdPreScaler_SysClkOut_by_4);
CLK_setClkOutPreScaler(obj->clkHandle,CLK_ClkOutPreScaler_SysClkOut_by_1);
PLL_setDivideSelect(obj->pllHandle,PLL_DivideSelect_ClkIn_by_2);
return;
} // end of HAL_setupClks() function