OSAL timer uses timer4 which is a 8 bit timer. However, it uses halTimerSetCount in Hal_timer.c to configure its timepertick value
uint8 halTimerSetCount (uint8 hwtimerid, uint32 timePerTick)
{
uint16 count;
uint8 high, low;
/* Load count = ((sec/tick) x clock) / prescale */
count = (uint16)((timePerTick * halTimerRecord[hwtimerid].clock) / halTimerRecord[hwtimerid].prescaleVal);
high = (uint8) (count >> 8);
low = (uint8) count;
*(halTimerChannel[hwtimerid].TxCCH) = high;
*(halTimerChannel[hwtimerid].TxCCL) = low;
return HAL_TIMER_OK;
}
This function is used to configure 16 bit timer. OSAL timer is 1ms tick , "timePerTick" is 1000 and the "count" value in this function is 250, which only occupies low 8 bit. So looks like it still works.
But my questions are:
1. T4CC0 register is only 8 bits, so I assume " *(halTimerChannel[hwtimerid].TxCCL) = low" will set the T4CC0 value to 250. But then how this code " *(halTimerChannel[hwtimerid].TxCCH) = high" is executed, In definition,
uint8 volatile XDATA *TxCCH;
uint8 volatile XDATA *TxCCL;
Both are volatile value in XDATA, so it seems both are register values, which register it will set by executing "*(halTimerChannel[hwtimerid].TxCCH) = high"?
2. if somehow I miss set "timePerTick" and "count" is larger than 256 which need High 8 bit timer setup, how is the outcome?(related to 1 question)
Thanks very much
Rui