001

2018.4.21 After reviewing the old and learning the new, you can be a teacher.

On the JZ2440 board, there is a GPIO controller, here I plan to use GPF4 as the output.

So how to make GPF4 output 1 or 0? It can be configured by: ① configure as output pin (configure GPFCON) ② set state (configure GPFDAT)

There is a CPU on the JZ2440 board, which has R0, R1...R15 registers, and these registers can be accessed directly by the CPU.

There are GPF1, GPF2...GPFCON/GPFDAT registers in the GPIO controller, which cannot be directly accessed by the CPU, but can only be accessed by address.

GPFCON configuration register (configuration pin F), GPFDAT data register (data register for pin F).

① First configure GPF4 as an output pin , look up the table to know:

GPF4 corresponds to GPFCON[9:8], when register 8bit is 1, the address is 0x00000100.

So write 0x100 to the register GPFCON, 0x56000050.

②Set the status , check the table to know:

GPF4 corresponds to GPFDAT[4], when register 4bit is 1, the address is 0x00000010; when register 4bit is 0, the address is 0.

There are two states for GPFDAT[4]:

①When the output is 1, it is high level, the light is off → write 0x10 to the address 0x56000054.

②When 0 is output, it is low level, the light is on → write 0 to the address 0x56000054.

What I want is to light up the LEDs on the board, so I choose the second way.

 

I use assembly code to write, briefly introduce the code instructions used.

①LDR (load): read memory, read 4 bytes.

LDR R0, [R1]

Assuming that the value of R1 is x, read the data (4 bytes) at address x and save it to R0.

②STR (store): write memory command, write 4 bytes.

STR  R0,[R1]

Assuming the value of R1 is x, write the value of R0 to address x.

③B: Jump

④MOV (move): assignment instruction

MOV  R0,R1

Assign the value of R1 to R0, that is, R0=R1.

MOV R0,#0x100→R0=0x100。

⑤ LDR pseudo-instruction

LDR  R0,#0x12345678

This is a pseudo-instruction whose final result is split into several real ARM instructions, and the instruction result makes R0=0x12345678.

 

If MOV R0,#0x12345678 is a bad instruction, why?

I'm used to Source Insight 3.5

code show as below:

 

 Connect to the server, upload led_on.S to the server with FileZilla,

 

This will get the led_on.bin file.

In fact, in order to facilitate future compilation, these codes can also be made into Makefile files.

In this way, you can use the make command to compile directly; the make clean command clears the generated files.

After getting led_on.bin, use FileZilla to copy the bin file from the server to windows.

Then use oflash to program the bin to Nand flash, set it to Nand start after power off, and turn on a led to light up.

 

2018.4.21 After reviewing the old and learning the new, you can be a teacher.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324609238&siteId=291194637
001