osal中timer初始化:
void osalTimerInit( void ) {osal_systemClock = 0; }
hal中初始化:
typedef struct {bool configured;bool intEnable;uint8 opMode;uint8 channel;uint8 channelMode;uint8 prescale;uint8 prescaleVal;uint8 clock;halTimerCBack_t callBackFunc; } halTimerSettings_t; typedef struct {uint8 volatile XDATA *TxCCTL;uint8 volatile XDATA *TxCCH;uint8 volatile XDATA *TxCCL;uint8 volatile XDATA *TxOVF;uint8 ovfbit;uint8 intbit; } halTimerChannel_t; /********************************************************************* * GLOBAL VARIABLES */ static halTimerSettings_t halTimerRecord[HW_TIMER_MAX]; static halTimerChannel_t halTimerChannel[HW_TIMER_MAX]; void HalTimerInit (void) {T1CCTL0 = 0;/* Make sure interrupts are disabled */T1CCTL1 = 0;/* Make sure interrupts are disabled */T1CCTL2 = 0;/* Make sure interrupts are disabled */T3CCTL0 = 0;/* Make sure interrupts are disabled */T3CCTL1 = 0;/* Make sure interrupts are disabled */T4CCTL0 = 0;/* Make sure interrupts are disabled */T4CCTL1 = 0;/* Make sure interrupts are disabled *//* Setup prescale & clock for timer0 */halTimerRecord[HW_TIMER_1].prescale= HAL_TIMER1_16_PRESCALE;halTimerRecord[HW_TIMER_1].clock= HAL_TIMER_32MHZ;halTimerRecord[HW_TIMER_1].prescaleVal = HAL_TIMER1_16_PRESCALE_VAL;/* Setup prescale & clock for timer2 */halTimerRecord[HW_TIMER_3].prescale= HAL_TIMER3_8_PRESCALE;halTimerRecord[HW_TIMER_3].clock= HAL_TIMER_32MHZ;halTimerRecord[HW_TIMER_3].prescaleVal = HAL_TIMER3_8_PRESCALE_VAL;/* Setup prescale & clock for timer3 */halTimerRecord[HW_TIMER_4].prescale= HAL_TIMER4_8_PRESCALE;halTimerRecord[HW_TIMER_4].clock= HAL_TIMER_32MHZ;halTimerRecord[HW_TIMER_4].prescaleVal = HAL_TIMER4_8_PRESCALE_VAL;/* Setup Timer1 Channel structure */halTimerChannel[HW_TIMER_1].TxCCTL = TCHN_T1CCTL;halTimerChannel[HW_TIMER_1].TxCCL =TCHN_T1CCL;halTimerChannel[HW_TIMER_1].TxCCH =TCHN_T1CCH;halTimerChannel[HW_TIMER_1].TxOVF =TCNH_T1OVF;halTimerChannel[HW_TIMER_1].ovfbit = TCHN_T1OVFBIT;halTimerChannel[HW_TIMER_1].intbit = TCHN_T1INTBIT;/* Setup Timer3 Channel structure */halTimerChannel[HW_TIMER_3].TxCCTL = TCHN_T3CCTL;halTimerChannel[HW_TIMER_3].TxCCL =TCHN_T3CCL;halTimerChannel[HW_TIMER_3].TxCCH =TCHN_T3CCH;halTimerChannel[HW_TIMER_3].TxOVF =TCNH_T3OVF;halTimerChannel[HW_TIMER_3].ovfbit = TCHN_T3OVFBIT;halTimerChannel[HW_TIMER_3].intbit = TCHN_T3INTBIT;/* Setup Timer4 Channel structure */halTimerChannel[HW_TIMER_4].TxCCTL = TCHN_T4CCTL;halTimerChannel[HW_TIMER_4].TxCCL =TCHN_T4CCL;halTimerChannel[HW_TIMER_4].TxCCH =TCHN_T4CCH;halTimerChannel[HW_TIMER_4].TxOVF =TCNH_T4OVF;halTimerChannel[HW_TIMER_4].ovfbit = TCHN_T4OVFBIT;halTimerChannel[HW_TIMER_4].intbit = TCHN_T4INTBIT; }
void InitBoard( uint8 level ) {if ( level == OB_COLD ){// Interrupts offosal_int_disable( INTS_ALL );// Turn all LEDs offHalLedSet( HAL_LED_ALL, HAL_LED_MODE_OFF );// Check for Brown-Out resetChkReset();}else // !OB_COLD{/* Initialize Key stuff */OnboardKeyIntEnable = HAL_KEY_INTERRUPT_DISABLE;//DISABLEHalKeyConfig( OnboardKeyIntEnable, OnBoard_KeyCallback);} }
这里也没有
我把hal_timer.h中HalTimerConfig和HalTimerStart屏蔽了也没有报错
请问系统时钟是在哪里开启的
VV:
这个是定时器的使用初始化。
SLEEPCMD &= ~OSC_PD; /* turn on 16MHz RC and 32MHz XOSC */ \ while (!(SLEEPSTA & XOSC_STB)); /* wait for 32MHz XOSC stable */ \ asm("NOP"); /* chip bug workaround */ \ for (i=0; i<504; i++) asm("NOP"); /* Require 63us delay for all revs */ \ CLKCONCMD = CLKCONCMD_VALUE; /* Select 32MHz XOSC and the source for 32K clock */ \ while (CLKCONSTA != CLKCONCMD_VALUE); /* Wait for the change to be effective */ \ SLEEPCMD |= OSC_PD; /* turn off 16MHz RC */
系统时钟是根据MAC Timer来更新的。
void osal_run_system( void ){ uint8 idx = 0;
osalTimeUpdate();…
}