1. In 32 bit, do all unsigned numeric constants should be suffixed by U or 32 bit should be suffixed by UL.
Is it:
uint8_t var_1 = 4U; uint16_t var_2 = 5U; uint32_t var_3 = 6U; uint64_t var_4 = 7UL; or uint8_t var_1 = 4U; uint16_t var_2 = 5U; uint32_t var_3 = 6UL; uint64_t var_4 = 7UL;
2. I have a code in which a var get incremented in ISR. This variable gets incrmented & read. What should be correct approach so that operation cannot be interrupted. As operation divides into three steps - Load, mdify & store.
In had tried second method, but again the instruction "var = temp", breaks into LDR & STR, again this can cause
interrupt in between. Is there any step so that this operation cannot be interrupted.
volatile uint8_t var; void isr(void) { var++; /* load, Add, Str */ } void main(void) { while(1); /* do something */ } or volatile uint8_t var; void isr(void) { uint8_t temp; temp = var; temp++; var = temp; /* load,store */ } void main(void) { while(1); /* do something */ }