2017-01-11 11:12 PM
hi ,i am using stm32f0 . I want to set or reset gpio pin by using assembly language programming . please help me
i am new in stm32f0
thank you
2017-01-12 01:09 AM
One way to start whit this is to write a simple program accomplishing port toggle in C and make the compiler output assembly for it, if your toolchain allows this (with gcc, use -S).
JW
2017-01-14 08:33 AM
hi, thank you@
Waclawek.Jan
In my code to set or reset gpio pin . because HAL Write (set and reset) take time . so for fast operation i want to used portmanipulation. but i didn't get how to do it ? i can set or reset pin by using BSRR ans BRR register. likeGPIOA->BSRR=(1<<4);// to set pin A4,GPIOA->BRR=(1<<4);// to reset pin A4. but i want to set or reset GPIO port A by using port manipulation . please help me2017-01-14 09:39 AM
I don't understand what's wrong with using GPIOx_BSRR?
You can write directly to GPIOx_ODR, but there are gotchas like atomicity ahead.
JW
2017-01-14 10:27 AM
JW is right. Normal mcu have a data register. If need to modify few bits (gpios) very fast, the core would read DR, do a bit AND mask to clear gpios that needs to be, theb OR with gpios to set high, then write back to thw DR. And oh, manually wrap a interrupt disable to avoid corruption if interrupts do modify the same GPIO port....
The BSSR and BRR register simplify the job, just with 2 Write operations, multiple gpios can be set and cleared with minimum cycles. No need Read/Modify/write opcode. With proper C style wrapping and proper compiler optimisation, it is possible to get as good as assembly programming. I stopped developping in asm 10 years back. For asm specific opcodes such as nop(), C macros exists. Alternatively to HAL, LL low layer library is one way to get there.
Another scheme would be, if suitableto your needs, to use DMA to write DR from SRAM buffer (assuming the whole port as outputs are for speedy output toggling. [Not tried yet]
2017-01-14 12:16 PM
LDR R0, =GPIOA_BSRR ; Address of GPIOA->BSRR
LDR R2, =0x00000010
LDR R3, =0x00100000STR R2, [R0]
STR R3, [R0] STR R2, [R0] STR R3, [R0]2017-01-16 08:02 AM
thank you@
Turvey.Clive.002
,Centauris.Alpha
,Waclawek.Jan
. my problem is solved .