Hello, I am using a discovery board with an STM32l152. The user push button is ported to PA0. I need to read from the IDR bit on the GPIOA when the button is pushed. I read that it can only be accessed via word only. I have already set up the moder, otyper, etc correctly and checked it against the debugger. Below is the offset address of GPIOA_IDR.
LDR r0, =0x40000000 ;PERIPH_BASE ADD r0, #0x20000 ;AHBPERIPH_BASE ADD r0, #0x0400 ;GPIOA_BASE ADD r0, #0x10 if((GPIOA-IDR & 0x1) == 1) turn on LED
I would like to do the the C statement above in assembly. Thank you very much
And your C line
if((GPIOA-IDR & 0x1) == 1) turn on LED
can be something like:
LDR r0, GPIOA_ADDR LDR R1,[R0] TST R1,#0x00000001 BEQ SkipIt ;TURN ON LED SkipIt: ;Carry on
ARM assembler isn't the easiest but it can be good fun and not many programmers bother with it because they think they can do everything in C and don't think they need to understand the low level stuff.