Tiny4412 assembly water light code, Tiny4412 bare metal LED operation

  
 

Starting today, I officially entered the development of tiny4412. Today I mainly watched the startup process and memory mapping of the Tiny4412 and the Exynos4412 datasheet. I wrote a marquee program with the sink (there will be a C language version later). Come out), let me talk about my development environment:

Development board: Tiny4412 enhanced version (the bottom plate is Tiny4412ADK 1312)

Development Tools: UltraEdit

Host: VmWare Ubuntu12.04(64bit)

Compilation Tools: arm-linux-gcc4.5.1

In order to facilitate classification management, we have specially opened a Tiny4412 learning area, I hope to help everyone, enter below The topic, talk about the marquee program.

I. Description of control principle
tiny4412 core board

First look at the schematic diagram:
tiny4412-led schematic diagram
tiny4412-led schematic diagram

As shown in the figure above, the Tiny4412 has 4 user LEDs. The four pins are controlled by GPM4_0~ GPM4_3. It can be seen from the principle that when the IO pin is high, the LED is off, when the IO pin is low. The LED is bright. The work we have to do is to set GPM4_0~ GPM4_3 as the output function, and control and output level can be high or low.

Second, program description

1.led.S

It is known from the schematic diagram that the program only performs two steps;

First step: Set the GPM4CON to GPM4_3 corresponding control register GPM4CON, so that the four pins GPM4_0~ GPM4_3 are output functions.
Tiny4412-GPM4CON

Step 2: Set the corresponding 4 bits of GPM4DAT to 0, make GPM4_0~ GPM4_3 low, 4 LEDs are all on, wait for a period Time sets the 0th bit to 0 and the remaining bits to 1 so that only the first light is on; wait for a while to set the 1st bit to 0, and the remaining bits to 1 so that only the second light is on; wait for a while The second bit is set to 0, and the remaining bits are set to 1, so that only the third light is on; wait for a while to set the third bit to 0, and the remaining bits to 1, so that only the fourth light is on; wait for a while to make GPM4_0~ GPM4_3 is all high level, and all 4 LED lights are off. This achieves the marquee effect.

In the program code, there are also related explanations here.
.text.globl _start_start:/** set GPM4 as output*/ldr r0, =0x110002E0 //The address of GPM4CON is 0x110002E0ldr r1, [r0] //Read the original value bic r1, r1, #0xff00 //Clear bit[15:8]bic r1, r1, #0xff //Clear bit[7:0]orr r1, r1, #0x1100 //Set bit[15:8] to 0b00010001orr r1, r1, #0x11 //Set bit[7:0] to 0b00010001str r1, [r0] //Write GPM4CON/** set GPM4DAT as Low For leds*/ldr r0, =0x110002E4 //The address of GPM4DAT is 0x110002E0ldr r1, [r0] //Read The original value leds_loop:bic r1, r1, #0xf //clear bit[0-3] to 0 full bright str r1, [r0] //write GPM4DATldr r2,=0xffffffbl delayorr r1, r1, #0xe //set Bit[0] is 0 LED1 is bright str r1, [r0] //Write GPM4DATldr r2,=0xffffffbl delaybic r1, r1, #0x3 //Set bit[1] to 0 LED2 is lit orr r1, r1, #1str r1, [r0] //Write GPM4DATldr r2,=0xffffffbl delaybic r1, r1, #0x6 //Set bit[2] to 0 LED3 is lit orr r1, r1, #2str r1, [r0] //Write GPM4DATldr r2,= 0xffffffbl delaybic r1, r1, #0xc //Set bit[3] to 0 LED4 on orr r1, r1, #4str r1, [r0] //write GPM4DATldr r2,=0xffffffbl delayorr r1, r1, #0xfstr r1, [r0] //Write GPM4DAT all off ldr r2,=0xffffffbl delayb leds_loophalt_loop:b halt_loopdelay://horse delay program sub r2,r2,#1 //sub subtraction cmp r2,#0x0 //Compare r0 with 0 bne delay //b is jump une is not equal, unequal jump to delaymov pc, lr /lr stored in the next instruction when calling the function, let the Pc pointer point to lr can complete the function Return

2. MakeFile Description
led.bin : led.Sarm-linux-gcc -c -o led.o led.Sarm-linux-ld -Tled.lds -N led.o -o led. Elfarm-linux-objcopy -O binary -S led.elf led.binarm-linux-objdump -D -m arm led.elf > led.disclean:rm -f *.dis *.bin *.elf *.o

When we execute the make command in the directory where the Makefile is located, the system will do the following:

Copyright © Windows knowledge All Rights Reserved