1 / 10

Intro. to CodeWarrior™--Running Assembly Programs on the Microcontroller

Intro. to CodeWarrior™--Running Assembly Programs on the Microcontroller. Freescale University Programs Document Number: LABS12CINTRO4S/REV1 Author: Fred Cady. Sample Code. LED1 and 2 will blink Export Symbols (assembler directive) XDEF Entry, main XREF ___SEG_END_STACK.

malina
Download Presentation

Intro. to CodeWarrior™--Running Assembly Programs on the Microcontroller

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Intro. to CodeWarrior™--Running Assembly Programs on the Microcontroller Freescale University Programs Document Number: LABS12CINTRO4S/REV1 Author: Fred Cady

  2. Sample Code • LED1 and 2 will blink • Export Symbols (assembler directive) • XDEF Entry, main • XREF ___SEG_END_STACK

  3. User Register Definitions • BASE: EQU 0 • PORTA: EQU BASE+0 • DDRA: EQU BASE+2 • PORTB: EQU BASE+1 • DDRB: EQU BASE+3 • LED1: EQU %00000001 ;A0 • LED2: EQU %00010000 ;B4

  4. User Constant Definitions • DELAY1: EQU $ffff ;inner lp cnt • DELAY2: EQU $04 ;outer lp cnt

  5. User code Section • MyCode: Section • main: • Entry:

  6. Initialize stack pointer register • LDS #__SEG_END_SSTACK

  7. Initialize I/O • bset DDRA,LED1 ;Make A0 output • bset DDRB,LED2 ;Make B4 output • ldaa #LED1 ;Initial LED Display • ldab #~LED2 ; ~ = 1’s comp.

  8. main_loop: ; DO ; Display the current pattern on the LEDs staa PORTA stab PORTB ;Delay some time jsr delay_sub

  9. main_loop (cont.) ;Complement the display values coma ; Complement A register comb ; Complement B register ; Forever bra main_loop

  10. delay_sub • See page 5 • X and Y are pushed on the stack. • DELAY2 is loaded into Y (initialization) • While Y is not zero, outer loop counter is decremented. • While X register is not zero; branch if zero to “all_done:”. • Inner loop is processed. • Registers are restored and then a return from subroutine occurs. • Result, LED’s blink at different rates.

More Related