Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SIM_SCGC5 EQU 0x40048038 ;SIM_SCGC5 address
- SIM_COPC EQU 0x40048100 ;SIM_COPC (watchdog) address
- PORTA_PCR2 EQU 0x40049008 ;PORTA_PCR2 (PTA2) address
- PORTA_PCR4 EQU 0x40049010 ;PORTA_PCR4 (PTA4) address
- PORTA_PCR5 EQU 0x40049014 ;PORTA_PCR5 (PTA5) address
- PORTC_PCR7 EQU 0x4004B01C ;PORTA_PCR7 (PTC7) address
- PORTA_PDDR EQU 0x400FF014
- PORTA_PDOR EQU 0x400FF000
- PORTC_PDDR EQU 0x400FF094
- PORTC_PDIR EQU 0x400FF090
- GREEN_MASK EQU 0x00000004 ; PORTA_PIN 2
- YELLOW_MASK EQU 0x00000010 ; PORTA_PIN 4
- RED_MASK EQU 0x00000020 ; PORTA_PIN 5
- INIT_MASKS EQU 0x00000034 ; PORTA_PIN 2, 4 and 5
- BUTTON_MASK EQU 0X00000080 ; PORTC_PIN 7
- DELAY_CNT EQU 0X00800000
- AREA asm_area, CODE, READONLY
- EXPORT asm_main
- asm_main ;assembly entry point for C function, do not delete
- ; Add program code here
- BL init_gpio
- loop
- BL greenon
- LDR R0, =DELAY_CNT
- BL delay
- BL redon
- LDR R0, =DELAY_CNT
- BL delay
- BL yellowon
- LDR R0, =DELAY_CNT
- BL delay
- B loop
- greenon
- LDR R0,=PORTA_PDOR ;Load address of GPIOB_PCOR to R0
- LDR R1,=GREEN_MASK ;Load value to R1
- STR R1,[R0] ;Put value into GPIOB_PCOR
- BX LR
- redon
- LDR R0,=PORTA_PDOR ;Load address of GPIOB_PSORto R0
- LDR R1,=RED_MASK ;Load value to R1
- STR R1,[R0] ;Put value into GPIOB_PSOR
- BX LR
- yellowon
- LDR R0,=PORTA_PDOR ;Load address of GPIOD_PTOR to R0
- LDR R1,=YELLOW_MASK ;Load value to R1
- STR R1,[R0] ;Put value into GPIOD_PTOR
- BX LR
- delay
- SUBS R0, #1
- BNE delay
- BX LR
- init_gpio
- ;Disable watchdog timer (COP)
- LDR R0,=SIM_COPC
- LDR R1,=0x0
- STR R1,[R0]
- ;Turns on clocks for all ports
- LDR R0,=SIM_SCGC5 ;Load address of SIM_SCGC5 to R0
- LDR R1,[R0] ;Get original value of SIM_SCGC5
- LDR R2,=0x00003E00 ;Load mask for bits to set to R2
- ORRS R1,R2 ;Set bits with OR of orig val and mask
- STR R1,[R0] ;Put new value back into SIM_SCGC5
- ; Set PORTS to appropriate MUX settings
- LDR R0,=PORTA_PCR2 ;Load address of PORTA_PCR2 to R0
- LDR R1,=0x01 ;Load new value to R1
- STR R1,[R0]
- ; Set PORTS to appropriate MUX settings
- LDR R0,=PORTA_PCR4 ;Load address of PORTA_PCR4 to R0
- LDR R1,=0x01 ;Load new value to R1
- STR R1,[R0]
- LDR R0,=PORTA_PCR5 ;Load address of PORTA_PCR5 to R0
- LDR R1,=0x01 ;Load new value to R1
- STR R1,[R0]
- LDR R0,=PORTC_PCR7 ;Load address of PORTC_PCR7 to R0
- LDR R1,=0x01 ;Load new value to R1
- STR R1,[R0]
- ; Setup PORTA Pins 2,4 and 5 to be outputs
- LDR R0,=PORTA_PDDR ;Load address of PORTB_PCR18 to R0
- LDR R1,=INIT_MASKS ;Load new value to R1
- STR R1,[R0] ;Put value into PORTB_PCR18
- ; Setup PORTC Pin 7 to be an input
- LDR R0,=PORTC_PDDR ; Load address of PORTC_PDDR to R0
- LDR R1,=BUTTON_MASK ;Load new value to R1
- STR R1,[R0] ;Put value into PORTC_PDDR
- BX LR
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement