cancel
Showing results for 
Search instead for 
Did you mean: 

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

SHald.1
Associate II

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Peter BENSCH
ST Employee

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.

View solution in original post

12 REPLIES 12
KnarfB
Principal III

> 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
ST Employee

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.

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

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.

Thank You Peter.

But, I tried everything and still getting same error.

.macro DEBUG_ToggleLED88

.equ RCC_BASE,0x58024400

.equ GPIOD_BASE,0x58020C00

.equ AHBENR_OFFSET,0xE0‬

.equ RCC_AHBENR,0x580244E0

.equ LED_D88_GPIO_Port,0x58020C00

.equ GPIODMODER_OFFSET,0x00

.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

If possible could you please suggest me where I am doing mistake here?

Thanks.

Snehashis

You still have strange bytes after

.equ AHBENR_OFFSET,0xE0

this time 0xE2, 0x80, 0xAC. Please try to delete this line completely and enter it again.

By the way: Source code is much more readable if you insert it here with the code snippet button </>.

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.

Hi Peter,

Even now, I have removed that line and still getting the error.

<

.macro DEBUG_ToggleLED88

  .equ RCC_BASE,0x58024400

  .equ GPIOD_BASE,0x58020C00‬

  .equ LED_D88_GPIO_Port,0x58020C00

  .equ GPIODMODER_OFFSET,0x00

  .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

/>

If possible could you please let me know if I am missing something?

Thanks.

Snehashis

You still have these strange three bytes, this time behind

.equ GPIOD_BASE,0x58020C00

I would therefore not only delete this line and re-enter it, but also the following one, in order to "catch" the three characters as well.

As far as inserting source code is concerned, there is a button bar at the bottom where the code snippet button </> can be found to the left of the smiley. Please press this button and copy the source code there.

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.

Hello Peter,

Its no working.

Do you think if there is any bug with the editor or the assembler?

.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