1 @ file : led_on.S 2 @ date : 02-01-2013 3 @ author: asicer@live.cn 4 5 @ nLED_1 <-> GPB5 6 @ nLED_2 <-> GPB6 7 @ nLED_3 <-> GPB7 8 @ nLED_4 <-> GPB8 9 @ n means low value enable light on. 10 @ That is, 0 turn light on and 1 turn it off. 11 12 @ GPBCON 0x56000010 Port B control 13 @ GPBDAT 0x56000014 Port B data 14 @ GPBUP 0x56000018 Pull-up control B 15 16 @ ________________________________________________ 17 @ | PBCON | BIT | Discription | 18 @ |-------|-----------|----------------------------| 19 @ | GPBx | [2x+1:2x] | 00 = Input 01 = Output | 20 @ | | | 10 = nXDREQ0 11 = reserved | 21 @ |_______|___________|____________________________| 22 23 @ ___________________________________________________________________________________________________ 24 @ | GPBDAT | Bit | Description | 25 @ |-----------|--------|------------------------------------------------------------------------------| 26 @ | GPB[10:0] | [10:0] | When the port is configured as input port, the corresponding bit is the pin | 27 @ | | | state. When the port is configured as output port, the pin state is the same | 28 @ | | | as the corresponding bit. When the port is configured as functional pin, the | 29 @ | | | undefined value will be read. | 30 @ |___________|________|______________________________________________________________________________| 31 32 @ ___________________________________________________________________________________________________ 33 @ | GPBUP | Bit | Description | 34 @ |-----------|--------|------------------------------------------------------------------------------| 35 @ | GPB[10:0] | [10:0] | 0: The pull up function attached to the corresponding port pin is enabled. | 36 @ | | | 1: The pull up function is disabled. | 37 @ |___________|________|______________________________________________________________________________| 38 39 @ The ARM microprocessor has 16 general-purpose registers. 40 @ THUMB has eight general-purpose registers, R0-R7, and access to the high registers, R8-R15. 41 42 @ The ARM Instruction Set 43 @ ________________________________________________________ 44 @ | Mnemonic | Instruction | Action | 45 @ |----------|---------------------------|-----------------| 46 @ | LDR | Load register from memory | Rd: = (address) | 47 @ |----------|---------------------------|-----------------| 48 @ | MOV | Move register or constant | Rd: = Op2 | 49 @ |----------|---------------------------|-----------------| 50 @ | STR | Store register to memory | <address>: = Rd | 51 @ |__________|___________________________|_________________| 52 53 .text 54 .global _start 55 56 _start: 57 58 @ following three instructions set the GBPCON 59 60 @ load register R0 from addr 0x56000010, it's GPBCON register. 61 LDR R0,=0x56000010 62 63 @ move immediate value 0x00015400 to register R1, 64 @ it's value is 0000_0000_0000_00_01_01_01_01_00_00_00_00_00 in binary, 65 @ that is, GPB5, GPB6, GPB7 and GPB8 all set to 01, function as output. 66 MOV R1,#0x00015400 67 68 @ store register R1 to memory at addr R0, that is, set GPBCON. 69 STR R1,[R0] 70 71 72 @ following three instructions set the GBPDAT 73 74 @ load register R0 from addr 0x56000014, it's GPBDAT register. 75 LDR R0,=0x56000014 76 77 @ move immediata value to register R1, 78 @ it's value is 0000_0000_0000_0000_0000_000x_xxx0_0000 in binary, 79 @ 0x00000000 GPB5/6/7/8=0/0/0/0 all on 80 @ 0x000001e0 GPB5/6/7/8=1/1/1/1 all off 81 @ 0x000001c0 GPB5/6/7/8=0/1/1/1 only LED_1 on xxx1_110x 82 @ 0x000001a0 GPB5/6/7/8=0/1/1/1 only LED_2 on xxx1_101x 83 @ 0x00000160 GPB5/6/7/8=0/1/1/1 only LED_3 on xxx1_011x 84 @ 0x000000e0 GPB5/6/7/8=0/1/1/1 only LED_4 on xxx0_111x 85 MOV R1,#0x000000e0 86 87 @ store register R1 to memory at addr R0, that is, set GPBDAT. 88 STR R1,[R0] 89 90 MAIN_LOOP: 91 B MAIN_LOOP