Other Parts Discussed in Thread:MOTORWARE
我看到F28027F的Flash:
Sector A(0x3F6000-0x3F7FFF)
Sector B(0x3F4000-0x3F5FFF)
Sector C(0x3F3000-0x3F3FFF)
Sector D(0x3F0000-0x3F1FFF)
1、那么我擦除Sector B,擦除范围是 0x3F4000-0x3F5FFF 吗?这样不是和其他几个Sector重复了吗?
2、我理解的Flash 扇区,是每个扇区互不相干的,地址不重复,但上面显示的每个Sector,都是地址重复的,我应该怎么理解?
3、另外,我只是想在片内的Flash,储存几个需要掉电记忆的参数,仅用到几个uint16的空间,我应该怎样使用Flash api?要全部擦除整个扇区再写入吗?
希望得到答复,万分感谢。
Best Regards!
Green Deng:
你好,这几个扇区都是独立的,没有重复啊,你是说哪里重复了?
擦除扇区都是按一个扇区来擦除的,最小单位就是一个扇区,不能按bit擦除。
,
user6301887:
明白了,之前看错,以为地址重复了。
另外我用flash api编程,按例程配置PLL,测试flash PLL时,发现引脚输出的频率是30KHz,并不是10KHz。检查了PLL的配置,没有发现问题。可以帮我看看我哪里出错了吗?
以下是程序:
void HAL_setupClks(HAL_Handle handle) {HAL_Obj *obj = (HAL_Obj *)handle;// enable internal oscillator 1CLK_enableOsc1(obj->clkHandle);// set the oscillator sourceCLK_setOscSrc(obj->clkHandle,CLK_OscSrc_Internal);// disable the external clock inCLK_disableClkIn(obj->clkHandle);// disable the crystal oscillatorCLK_disableCrystalOsc(obj->clkHandle);// disable oscillator 2CLK_disableOsc2(obj->clkHandle);// set the low speed clock prescalerCLK_setLowSpdPreScaler(obj->clkHandle,CLK_LowSpdPreScaler_SysClkOut_by_4);// set the clock out prescalerCLK_setClkOutPreScaler(obj->clkHandle,CLK_ClkOutPreScaler_SysClkOut_by_1);return; } // end of HAL_setupClks() functionvoid HAL_setupPll(HAL_Handle handle,const PLL_ClkFreq_e clkFreq) {HAL_Obj *obj = (HAL_Obj *)handle;// make sure PLL is not running in limp modeif(PLL_getClkStatus(obj->pllHandle) != PLL_ClkStatus_Normal){// reset the clock detectPLL_resetClkDetect(obj->pllHandle);// ???????asm("ESTOP0");}// Divide Select must be ClkIn/4 before the clock rate can be changedif(PLL_getDivideSelect(obj->pllHandle) != PLL_DivideSelect_ClkIn_by_4){PLL_setDivideSelect(obj->pllHandle,PLL_DivideSelect_ClkIn_by_4);}if(PLL_getClkFreq(obj->pllHandle) != clkFreq){// disable the clock detectPLL_disableClkDetect(obj->pllHandle);// set the clock ratePLL_setClkFreq(obj->pllHandle,clkFreq);}// wait until lockedwhile(PLL_getLockStatus(obj->pllHandle) != PLL_LockStatus_Done) {}// enable the clock detectPLL_enableClkDetect(obj->pllHandle);// set divide select to ClkIn/2 to get desired clock rate// NOTE: clock must be locked before setting this registerPLL_setDivideSelect(obj->pllHandle,PLL_DivideSelect_ClkIn_by_2);//PLL_setDivideSelect(obj->pllHandle,PLL_DivideSelect_ClkIn_by_4);return; } // end of HAL_setupPll() functionvoid HAL_setupPeripheralClks(HAL_Handle handle) {HAL_Obj *obj = (HAL_Obj *)handle;CLK_enableAdcClock(obj->clkHandle);CLK_enableCompClock(obj->clkHandle,CLK_CompNumber_1);CLK_enableCompClock(obj->clkHandle,CLK_CompNumber_2);CLK_enableCompClock(obj->clkHandle,CLK_CompNumber_3);CLK_enableEcap1Clock(obj->clkHandle);CLK_enablePwmClock(obj->clkHandle,PWM_Number_1);CLK_enablePwmClock(obj->clkHandle,PWM_Number_2);CLK_enablePwmClock(obj->clkHandle,PWM_Number_3);CLK_enablePwmClock(obj->clkHandle,PWM_Number_4);CLK_disableHrPwmClock(obj->clkHandle);CLK_disableI2cClock(obj->clkHandle);CLK_enableSciaClock(obj->clkHandle);CLK_enableSpiaClock(obj->clkHandle);CLK_enableTbClockSync(obj->clkHandle);CLK_enablePwmClock(obj->clkHandle,PWM_Number_4);//cywen addreturn; } // end of HAL_setupPeripheralClks() function#define GPBMUX1 (volatile Uint32*)0x00006F98 // GPIO B mux 1 #define GPBTOGGLE (volatile Uint32*)0x00006FCE // GPIO B toggle #define GPBDIR (volatile Uint32*)0x00006F9A // GPIO B dir #define GPIO32_MASK (Uint32)0x00000001 // GPIO32 maskvoid main(void) {// setup the clocksHAL_setupClks(handle);// Setup the PLLHAL_setupPll(handle,PLL_ClkFreq_60_MHz);// setup the PIEHAL_setupPie(handle);// run the device calibrationHAL_cal(handle);// setup the peripheral clocksHAL_setupPeripheralClks(handle);Status = Example_CsmUnlock();if(Status != STATUS_SUCCESS){//Example_Error(Status);}EALLOW;Flash_CPUScaleFactor = SCALE_FACTOR;EDIS;EALLOW;Flash_CallbackPtr = NULL;//&MyCallbackFunction;EDIS;//MyCallbackCounter = 0; // Increment this counter in the callback function// BEFORE calling the toggle test, configure the desired pin to be a GPIO // output pin. For this example, configure GPIO32 as a GPIO outputEALLOW; // Macro for asm(“ EALLOW);*GPBMUX1 = 0x00000000; // All GPIO B pins are GPIO*GPBDIR = 0x00000001; // All GPIO B pins are outputsEDIS;// Call the Toggle Test function. This function will run forever // and will not exit.Flash_ToggleTest(GPBTOGGLE,GPIO32_MASK);// enable global interruptsHAL_enableGlobalInts(halHandle);// enable debug interruptsHAL_enableDebugInt(halHandle); }
,
Green Deng:
请问你这部分程序是参考了哪里的例程吗?我看不到里面具体的数值,不知道怎么配置的。
,
user6301887:
是PLL配置是motorware里的lab05b例程,没做修改;其他flash配置参考了flash api例程;
lab05b例程里,我看PLL配置看不错有什么问题,但运行Flash_ToggleTest(GPBTOGGLE,GPIO32_MASK);函数时,输出的PWM频率却是30kHz。
希望可以得到解决,感谢。Best Regards