This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

EK-TM4C129EXL: Booting issue

Part Number: EK-TM4C129EXL

I am attempting to write assembly code for my EK-TM4C129EXL that will turn on LED’s 3 and 4 when user switch one is pressed, wait a few seconds and then turn off the LED’s.  Then if the other user switch is pressed, turn on the other LED’s.  I have the C code written and it works.  I turned it into assembly and I keep getting the following C file and line pop up:

It is always the same highlighted line (133) and my code does not work.  I am not sure why this is happening.  I do not see anything wrong with my code.  The only thing missing from my code is the timer which I will add later.  Here though is my assembly code:

       .thumb

       .text

 

       .align 4

GPIO_PORTN .word 0x40064000

GPIO_PORTJ .word 0x40060000

GPIO_PORTF .word 0x4005D000

SYSCTL    .word 0x400fe000

 

       .align 4

GPIO_PIN_0 .equ (1>>0)

GPIO_PIN_1 .equ (1<<1)

GPIO_PIN_4 .equ (1<<4)

 

       .align 4

LED1_PN1 .equ GPIO_PIN_1

LED2_PN0 .equ GPIO_PIN_0

LED3_PF4 .equ GPIO_PIN_4

LED4_PF0 .equ GPIO_PIN_0

 

       .align 4

SYSCTL_RCGCGPIO_PORTF .equ (1<<5)

SYSCTL_RCGCGPIO_PORTJ .equ (1<<8)

SYSCTL_RCGCGPIO_PORTN .equ (1<<12)

 

       .align 4

PUSH1_PJ0 .equ GPIO_PIN_0

PUSH2_PJ1 .equ GPIO_PIN_1

 

       .align 4

SYSCTL_RCGCGPIO .equ 0x608

GPIO_DIR .equ 0x400

GPIO_PUR .equ 0x510

GPIO_DEN .equ 0x51c

 

       .global main

 

main:

       .align 4

       push {R0-R5,LR}

       ldr R1, SYSCTL

       ldr R0, [R1, #SYSCTL_RCGCGPIO]

       orr R0, #SYSCTL_RCGCGPIO_PORTN

       str R0, [R1, #SYSCTL_RCGCGPIO]

 

       ldr R1, SYSCTL

       ldr R0, [R1, #SYSCTL_RCGCGPIO]

       orr R0, #SYSCTL_RCGCGPIO_PORTN

       str R0, [R1, #SYSCTL_RCGCGPIO]

 

       ldr R1, SYSCTL

       ldr R0, [R1, #SYSCTL_RCGCGPIO]

       orr R0, #SYSCTL_RCGCGPIO_PORTF

       str R0, [R1, #SYSCTL_RCGCGPIO]

 

       ldr R1, SYSCTL

       ldr R0, [R1, #SYSCTL_RCGCGPIO]

       orr R0, #SYSCTL_RCGCGPIO_PORTF

       str R0, [R1, #SYSCTL_RCGCGPIO]

 

       ldr R1, SYSCTL

       ldr R0, [R1, #SYSCTL_RCGCGPIO]

       orr R0, #SYSCTL_RCGCGPIO_PORTJ

       str R0, [R1, #SYSCTL_RCGCGPIO]

 

       ldr R1, SYSCTL

       ldr R0, [R1, #SYSCTL_RCGCGPIO]

       orr R0, #SYSCTL_RCGCGPIO_PORTJ

       str R0, [R1, #SYSCTL_RCGCGPIO]

 

       ldr R1, GPIO_PORTN

       ldr R0, [R1, #GPIO_DIR]

       orr R0, #LED1_PN1

       str R0, [R1, #GPIO_DIR]

 

       ldr R1, GPIO_PORTN

       ldr R0, [R1, #GPIO_DIR]

       orr R0, #LED2_PN0

       str R0, [R1, #GPIO_DIR]

 

       ldr R3, GPIO_PORTF

       ldr R2, [R3, #GPIO_DIR]

       orr R2, #LED3_PF4

       str R2, [R3, #GPIO_DIR]

 

       ldr R3, GPIO_PORTF

       ldr R2, [R3, #GPIO_DIR]

       orr R2, #LED4_PF0

       str R2, [R3, #GPIO_DIR]

 

       ldr R1, GPIO_PORTN

       ldr R0, [R1, #GPIO_DEN]

       orr R0, #LED1_PN1

       str R0, [R1, #GPIO_DEN]

 

       ldr R1, GPIO_PORTN

       ldr R0, [R1, #GPIO_DEN]

       orr R0, #LED2_PN0

       str R0, [R1, #GPIO_DEN]

 

       ldr R3, GPIO_PORTF

       ldr R2, [R3, #GPIO_DEN]

       orr R2, #LED3_PF4

       str R2, [R3, #GPIO_DEN]

 

       ldr R3, GPIO_PORTF

       ldr R2, [R3, #GPIO_DEN]

       orr R2, #LED4_PF0

       str R2, [R3, #GPIO_DEN]

 

       ldr R5, GPIO_PORTJ

       ldr R4, [R5, #GPIO_PUR]

       orr R4, #PUSH1_PJ0

       orr R4, #PUSH2_PJ1

       str R4, [R5, #GPIO_PUR]

 

       ldr R5, GPIO_PORTJ

       ldr R4, [R5, #GPIO_DEN]

       orr R4, #PUSH1_PJ0

       orr R4, #PUSH2_PJ1

       str R4, [R5, #GPIO_DEN]

 

       b loop

       pop {R0-R5,PC}

 

loop:

       ldr R5, GPIO_PORTJ

       ldr R4, [R5, #PUSH2_PJ1]

       cmp R4, #0

       bne left

       ldr R4, [R5, #PUSH1_PJ0]

       cmp R0, #0

       bne right

       b loop

 

left:

       ldr R1, GPIO_PORTN

       ldr R0, [R1, #LED1_PN1]

       eor R0, #LED1_PN1

       str R0, [R1, #LED1_PN1]

       ldr R1, GPIO_PORTN

       ldr R0, [R1, #LED2_PN0]

       eor R0, #LED2_PN0

       str R0, [R1, #LED2_PN0]

       b loop

 

right:

       ldr R3, GPIO_PORTF

       ldr R2, [R3, #LED3_PF4]

       eor R2, #LED3_PF4

       str R2, [R3, #LED3_PF4]

       ldr R3, GPIO_PORTF

       ldr R2, [R3, #LED4_PF0]

       eor R2, #LED4_PF0

       str R2, [R3, #LED4_PF0]

       b loop

 

       .end

 

 

Any guidance would be appreciated.  Thank you.

I am attempting to write assembly code for my EK-TM4C129EXL that will turn on LED’s 3 and 4 when user switch one is pressed, wait a few seconds and then turn off the LED’s.  Then if the other user switch is pressed, turn on the other LED’s.  I have the C code written and it works.  I turned it into assembly and I keep getting the following C file and line pop up:

It is always the same highlighted line (133) and my code does not work.  I am not sure why this is happening.  I do not see anything wrong with my code.  The only thing missing from my code is the timer which I will add later.  Here though is my assembly code:

       .thumb

       .text

 

       .align 4

GPIO_PORTN .word 0x40064000

GPIO_PORTJ .word 0x40060000

GPIO_PORTF .word 0x4005D000

SYSCTL    .word 0x400fe000

 

       .align 4

GPIO_PIN_0 .equ (1>>0)

GPIO_PIN_1 .equ (1<<1)

GPIO_PIN_4 .equ (1<<4)

 

       .align 4

LED1_PN1 .equ GPIO_PIN_1

LED2_PN0 .equ GPIO_PIN_0

LED3_PF4 .equ GPIO_PIN_4

LED4_PF0 .equ GPIO_PIN_0

 

       .align 4

SYSCTL_RCGCGPIO_PORTF .equ (1<<5)

SYSCTL_RCGCGPIO_PORTJ .equ (1<<8)

SYSCTL_RCGCGPIO_PORTN .equ (1<<12)

 

       .align 4

PUSH1_PJ0 .equ GPIO_PIN_0

PUSH2_PJ1 .equ GPIO_PIN_1

 

       .align 4

SYSCTL_RCGCGPIO .equ 0x608

GPIO_DIR .equ 0x400

GPIO_PUR .equ 0x510

GPIO_DEN .equ 0x51c

 

       .global main

 

main:

       .align 4

       push {R0-R5,LR}

       ldr R1, SYSCTL

       ldr R0, [R1, #SYSCTL_RCGCGPIO]

       orr R0, #SYSCTL_RCGCGPIO_PORTN

       str R0, [R1, #SYSCTL_RCGCGPIO]

 

       ldr R1, SYSCTL

       ldr R0, [R1, #SYSCTL_RCGCGPIO]

       orr R0, #SYSCTL_RCGCGPIO_PORTN

       str R0, [R1, #SYSCTL_RCGCGPIO]

 

       ldr R1, SYSCTL

       ldr R0, [R1, #SYSCTL_RCGCGPIO]

       orr R0, #SYSCTL_RCGCGPIO_PORTF

       str R0, [R1, #SYSCTL_RCGCGPIO]

 

       ldr R1, SYSCTL

       ldr R0, [R1, #SYSCTL_RCGCGPIO]

       orr R0, #SYSCTL_RCGCGPIO_PORTF

       str R0, [R1, #SYSCTL_RCGCGPIO]

 

       ldr R1, SYSCTL

       ldr R0, [R1, #SYSCTL_RCGCGPIO]

       orr R0, #SYSCTL_RCGCGPIO_PORTJ

       str R0, [R1, #SYSCTL_RCGCGPIO]

 

       ldr R1, SYSCTL

       ldr R0, [R1, #SYSCTL_RCGCGPIO]

       orr R0, #SYSCTL_RCGCGPIO_PORTJ

       str R0, [R1, #SYSCTL_RCGCGPIO]

 

       ldr R1, GPIO_PORTN

       ldr R0, [R1, #GPIO_DIR]

       orr R0, #LED1_PN1

       str R0, [R1, #GPIO_DIR]

 

       ldr R1, GPIO_PORTN

       ldr R0, [R1, #GPIO_DIR]

       orr R0, #LED2_PN0

       str R0, [R1, #GPIO_DIR]

 

       ldr R3, GPIO_PORTF

       ldr R2, [R3, #GPIO_DIR]

       orr R2, #LED3_PF4

       str R2, [R3, #GPIO_DIR]

 

       ldr R3, GPIO_PORTF

       ldr R2, [R3, #GPIO_DIR]

       orr R2, #LED4_PF0

       str R2, [R3, #GPIO_DIR]

 

       ldr R1, GPIO_PORTN

       ldr R0, [R1, #GPIO_DEN]

       orr R0, #LED1_PN1

       str R0, [R1, #GPIO_DEN]

 

       ldr R1, GPIO_PORTN

       ldr R0, [R1, #GPIO_DEN]

       orr R0, #LED2_PN0

       str R0, [R1, #GPIO_DEN]

 

       ldr R3, GPIO_PORTF

       ldr R2, [R3, #GPIO_DEN]

       orr R2, #LED3_PF4

       str R2, [R3, #GPIO_DEN]

 

       ldr R3, GPIO_PORTF

       ldr R2, [R3, #GPIO_DEN]

       orr R2, #LED4_PF0

       str R2, [R3, #GPIO_DEN]

 

       ldr R5, GPIO_PORTJ

       ldr R4, [R5, #GPIO_PUR]

       orr R4, #PUSH1_PJ0

       orr R4, #PUSH2_PJ1

       str R4, [R5, #GPIO_PUR]

 

       ldr R5, GPIO_PORTJ

       ldr R4, [R5, #GPIO_DEN]

       orr R4, #PUSH1_PJ0

       orr R4, #PUSH2_PJ1

       str R4, [R5, #GPIO_DEN]

 

       b loop

       pop {R0-R5,PC}

 

loop:

       ldr R5, GPIO_PORTJ

       ldr R4, [R5, #PUSH2_PJ1]

       cmp R4, #0

       bne left

       ldr R4, [R5, #PUSH1_PJ0]

       cmp R0, #0

       bne right

       b loop

 

left:

       ldr R1, GPIO_PORTN

       ldr R0, [R1, #LED1_PN1]

       eor R0, #LED1_PN1

       str R0, [R1, #LED1_PN1]

       ldr R1, GPIO_PORTN

       ldr R0, [R1, #LED2_PN0]

       eor R0, #LED2_PN0

       str R0, [R1, #LED2_PN0]

       b loop

 

right:

       ldr R3, GPIO_PORTF

       ldr R2, [R3, #LED3_PF4]

       eor R2, #LED3_PF4

       str R2, [R3, #LED3_PF4]

       ldr R3, GPIO_PORTF

       ldr R2, [R3, #LED4_PF0]

       eor R2, #LED4_PF0

       str R2, [R3, #LED4_PF0]

       b loop

 

       .end

 

 

Any guidance would be appreciated.  Thank you.

  • Hello,

    I turned it into assembly and I keep getting the following C file and line pop up:

    It is always the same highlighted line (133) and my code does not work.  I am not sure why this is happening.

    I'm not sure I understand the scenario. Is execution of the program halting at that line on its own for no apparent reason?

    thanks

    ki

  • Hello,

         When the assembly code is debugged, that C file pops up highlighting that line.  I press the play button, but the code does not seem to be executing on the board.  I press the switches, but nothing happens.  The program does not seem to be halting, it is not running for any apparent reason.

    Thank you for your response,

    Drew

  • When the assembly code is debugged, that C file pops up highlighting that line. 

    That is the entry point of your application. When a program is loaded, the debugger will set the program counter to the entry point of the program. For example, when i load an example on my Tiva board and disable auto-run to main, it open the same source file and be halted at line 133:

    This is expected behavior when auto-run to main is disabled. 

    I press the play button, but the code does not seem to be executing on the board

    There is some issue with your application. I will bring this thread to the attention of the device experts for further assistance.

    thanks

    ki

  • Hello,

         Strange, I'm not sure if there is an assembly thing that I need to do in order for it to run to main, but ok.

         Thank you for passing on this thread.

    Drew

  • Hi Drew,

      What is your reason to build a program using assembly? I really don't see any benefit doing so. As a matter of fact, assembly code is prone to mistakes and takes much longer development time. I haven't really seen anyone on forum doing assembly for an entire project.  With the compiler optimizer enabled, I really doubt you will gain much performance with code written in assembly vs the optimized C code.  With that said, I will suggest you single step your code after line 133 if you want to debug it. I can't really help in assembly debugging. For the C program, you can compile it to also generate an assembly listing file if you want to see the assembly code. 

  • Hi,

         I am writing in assembly for 2 reasons:

    1. I already wrote the code in C and am trying to transfer it over to assembly for practice with assembly.  Although it might take longer, I prefer assembly to C as I can manage the software better.
    2. I am applying to jobs and some I have found say that they want assembly knowledge.  Since assembly is an option for a project in Code Composer Studio, I thought that that would be a great opportunity to refresh my assembly knowledge.

    I can step through my assembly program and see which line is producing the auto-main failure.  I know I could find the assembly code from the compiled C code, but I dont want to cheat to the finish.  I'd rather do it myself.

    Thank you for your assistance,

    Drew