2023-02-13 04:25 AM
I wrote the below assembly macro in startup.S file.
.macro DEBUG_ToggleLED88
/*Enable clock to the Peripheral
Set the pin to output
Toggle PD14
*/
.equ RCC_BASE, 0x58024400
.equ GPIOD_BASE,0x58020C00
.equ AHB4ENR_OFFSET,0x0E0
.equ RCC_AHB4ENR, 0x580244E0
.equ LED_D88_GPIO_Port,GPIOD_BASE
.equ GPIODMODER_OFFSET,0x00
.equ GPIODODR_OFFSET,0x14
.equ GPIODBSRR_OFFSET, 0x18
.equ RCC_AHB4ENR_GPIODEN_Msk,0x00000008
.equ GPIO_MODER_MODE14_0,0x10000000
.equ GPIO_BSRR_BS14_Msk,0x00004000
.equ GPIO_BSRR_BR14_Msk,0x40000000
.equ GPIOD_MODER,0x58020C00
.equ GPIOD_ODR,0x58020C14
.equ GPIOD_BSRR,0x58020C18
/*RCC->AHB4ENR |= RCC_AHB4ENR_GPIODEN_Msk*/
/*---------------------------------------*/
/*Load address of RCC_AHB4ENR to R0* */
LDR R0,=RCC_AHB4ENR
/*LOAD the Value at address found in R0 into R1*/
LDR R1,[R0]
/*Bitwise OR on the value in R1*/
ORR R1,#RCC_AHB4ENR_GPIODEN_Msk
/*Store the content in R1 back at address found in R0*/
STR R1,[R0]
/*GPIOD->MODER |=GPIO_MODER_MODE14_0*/
/*--------------------------------------*/
/*Load address of GPIOD_MODER to R0*/
LDR R0,=GPIOD_MODER
/*LOAD the Value at address found in R0 into R1*/
LDR R1,[R0]
/*Bitwise OR on the value in R1*/
ORR R1,#GPIO_MODER_MODE14_0
/*Store the content in R1 back at address found in R0*/
/*GPIOD->BSRR |=GPIO_BSRR_BS14_Msk*/
/*-----------------------------------------*/
/*Load address of GPIOD_ODR to R0*/
LDR R0,=GPIOD_BSRR
/*LOAD the Value at address found in R0 into R1*/
LDR R1,[R0]
/*Bitwise OR on the value in R1*/
ORR R1,#GPIO_BSRR_BS14_Msk
/*Store the content in R1 back at address found in R0*/
STR R1,[R0]
/*GPIOD->BSRR |=GPIO_BSRR_BR14_Msk*/
LDR R0,=GPIOD_BSRR
/*LOAD the Value at address found in R0 into R1*/
LDR R1,[R0]
/*Bitwise OR on the value in R1*/
ORR R1,#GPIO_BSRR_BR14_Msk
/*Store the content in R1 back at address found in R0*/
STR R1,[R0]
.endm
But, the assembler throws the Error: junk at end of line, first unrecognized character valued 0xffffffe2
How to resolve it?
Solved! Go to Solution.
2023-02-15 02:34 AM
I can't explain the cause of these three ominous bytes that seem to keep slipping up. Please mark the entire macro, then delete it and reinsert it from the cleaned-up code below:
.macro DEBUG_ToggleLED88
.equ RCC_BASE,0x58024400
.equ LED_D88_GPIO_Port,0x58020C00
.equ GPIOD_BASE,0x58020C00
.equ GPIODODR_OFFSET,0x14
.equ GPIODBSRR_OFFSET,0x18
.equ RCC_AHBENR_GPIODEN_Msk,0x00000008
.equ GPIO_MODER_MODE14_0,0x10000000
.equ GPIO_BSRR_BS14_Msk,0x00004000
.equ GPIO_BSRR_BR14_Msk,0x40000000
.equ GPIOD_MODER,0x58020C00
.equ GPIOD_ODR,0x58020C14
.equ GPIOD_BSRR,0x58020C18
LDR R0,=RCC_AHBENR
LDR R1,[R0]
ORR R1,#RCC_AHBENR_GPIODEN_Msk
STR R1,[R0]
LDR R0,=GPIOD_MODER
LDR R1,[R0]
ORR R1,#GPIO_MODER_MODE14_0
LDR R0,=GPIOD_BSRR
LDR R1,[R0]
ORR R1,#GPIO_BSRR_BS14_Msk
STR R1,[R0]
LDR R0,=GPIOD_BSRR
LDR R1,[R0]
ORR R1,#GPIO_BSRR_BR14_Msk
STR R1,[R0]
.endm
2023-02-15 02:38 AM
Hello Peter,
Thank You very much.
With the code snippet provided by you the issue got resolved.
Thank you again.
Best Regards,
Snehashis
2023-02-15 02:57 AM
Great!
If the problem is solved, please mark this thread as answered by selecting Select as best, as also explained here. This will help other users find that answer faster.
Regards
/Peter