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
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).
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 port manipulation . but i didn't get how to do it ? i can set or reset pin by using BSRR ans BRR register. like GPIOA->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 me
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 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]
LDR R0, =GPIOA_BSRR ; Address of GPIOA->BSRR
LDR R2, =0x00000010 LDR R3, =0x00100000
STR R2, [R0] STR R3, [R0] STR R2, [R0] STR R3, [R0]
thank you @ Clive One,KIC8462852 EPIC204278916 , waclawek.jan. my problem is solved .
Retrieving data ...