Hello.
I'm using Cortex-M3 processor.
I want to test systick count flag.
I use the following code:
bool isSysTickElapsed() { return HWREGBITW(NVIC_ST_CTRL,16)==1; }
but it doesn't work: the processor skip the program flow.
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hello.
I'm using Cortex-M3 processor.
I want to test systick count flag.
I use the following code:
bool isSysTickElapsed() { return HWREGBITW(NVIC_ST_CTRL,16)==1; }
but it doesn't work: the processor skip the program flow.
Hi Mauro,
What is the disassembly generated by the compiler for that line of code
SysTickElapsed:
0x20001B04: 4903 LDR R1, $C$CON12
0x20001B06: 6809 LDR R1, [R1]
0x20001B08: 2000 MOV R0, #0x0
0x20001B0A: 2901 CMP R1, #0x1
0x20001B0C: D100 BNE $C$L4
0x20001B0E: 2001 MOV R0, #0x1
... finally I use this solution ...
tBoolean SysTickElapsed()
{
#define maskbit (x,y) (HWREG(x)&(1<<(y)))
return maskbit(NVIC_ST_CTRL,16)!=0;
}
... but I prefer to use TI macros
Mauro,
The HWREGBITW macros make use of a special part of the memory map to access an individual bit in RAM. Only the RAMs and peripherals are accessable through this bit-banded address space. The NVIC (which lies at 0xE000E000) isn't included in the bit-banded memory and thus cannot be accessed with the HWREGBITW macro. Your macro will work fine though and is just as good as something a TI'er would write.
Trey