I've come across some c code for a PIC timer where we can either load a value directly into the timer, define a 16-bit variable and split its high and low bytes into their respective registers (TMRH and TMRL), or define another uint16_t variable like this:
load a value directly into the timer
Split its high and low bytes into their respective registers (TMRH and TMRL),
Could you explain the benefits of each approach and when it's preferable to use one over the other?
load a value directly into the timer
Code:
uint16_t TMR = 1110; // Define a 16-bit variable with an initial value of 1110
Code:
uint16_t values = 1110; // Define another 16-bit variable with an initial value of 1110
// Split the high and low bytes into their respective registers
TMRH = (values >> 8) & 0xFF; // Load the high byte of 'values' with 4
TMRL = values & 0xFF; // Load the low byte of 'values' with 74