Skip to main content
SHald.1
Associate II
February 13, 2023
Solved

Error: junk at end of line, first unrecognized character valued 0xffffffe2

  • February 13, 2023
  • 3 replies
  • 11192 views

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?

    This topic has been closed for replies.
    Best answer by Peter BENSCH

    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

    3 replies

    KnarfB
    Super User
    February 13, 2023

    > junk at end of line

    check around that line for strange /unicode chars that may have slipped in from copy and paste. Try to find an editor/tool that can vizualize non-ASCII chars.

    hth

    KnarfB

    Peter BENSCH
    Technical Moderator
    February 13, 2023

    As @KnarfB​ already mentioned, the error occurs when inserting the macro, whereby the code is checked. Visibly there is also no error, but at the end of the line 

    .equ AHB4ENR_OFFSET,0x0E0‬

    there are three invisible special characters (0xD4, 0xC7, 0xBC) at the end of the line that prevent assembly.

    Regards

    /Peter

    In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
    SHald.1
    SHald.1Author
    Associate II
    February 14, 2023

    Hi Peter,

    Thank You for this information. As those are invisible characters, I am not able to resolve this issue.

    If possible could you please let me know how to resolve it? For this macro, I did not copy paste. SO, not sure how it got introduced. Here I am using STM32CubeIDE editor.

    Thanks.

    Snehashis

    Peter BENSCH
    Technical Moderator
    February 14, 2023

    I used Notepad++ for this, which can recognise the special characters, but I'm sure there are other editors that can do this as well.

    However, it should also be possible using the editor of the STM32CubeIDE to position the cursor at the end of the line immediately after the last character and then use Delete to remove all characters including the line feed, then only insert the line feed again.

    Regards

    /Peter

    In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
    Peter BENSCH
    Peter BENSCHBest answer
    Technical Moderator
    February 15, 2023

    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

    In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
    SHald.1
    SHald.1Author
    Associate II
    February 15, 2023

    Hello Peter,

    Thank You very much.

    With the code snippet provided by you the issue got resolved.

    Thank you again.

    Best Regards,

    Snehashis

    Peter BENSCH
    Technical Moderator
    February 15, 2023

    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

    In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.