ARM9 - first program PDF Print E-mail
User Rating: / 0
PoorBest 
Written by Dominik   
Sunday, 30 January 2011 21:39

This article presents how to write and run first program for microprocessor ARM9. W use uc EP9302 which is made by Cirrus Logic. Aplications work on evaluation board with preinstalled Linux:

http://www.olimex.com/dev/cs-e930x.html

The best way to download new programs and run them on the board is by
using local network. PC computer and ARM9 evaluation board should be
connected to the same local network.

First we should install tftp (ang. Trivial File Transfer Protocol serwer)
on aour PC. If we use linux the easiest way is to use applications from
repositoriews (e.g. atftpd). For Windows it could be:

http://www.solarwinds.com/products/freetools/free_tftp_server.aspx

To compile our applicatio we will use gcc:

http://arm.cirrus.com/files/tools/arm-linux-gcc-3.4.3-1.0.1.tar.bz2

Next downloaded archive should be extracted to /usr/local/. Now we can
write our first application. To have full access to EP9302 we will use
mmap() function. We can create file test.c:

#include<unistd.h>
#include<sys/types.h>
#include<sys/mman.h>
#include<fcntl.h>
#include<stdio.h>

volatile unsigned int *PADR, *PADDR, *PEDR, *PEDDR, *PBDR, *PBDDR,
*GPIOBDB, *GPIOADB;
unsigned char *start;

int main(void){



int fd = open("/dev/mem", O_RDWR);
start = (unsigned char *)mmap(0, getpagesize(), PROT_READ|PROT_WRITE,
MAP_SHARED,
fd, 0x80840000);
PADR = (unsigned int *)(start + 0x00); //port A
PADDR = (unsigned int *)(start + 0x10); //port B direction
PBDR = (unsigned int *)(start + 0x04); //port B
PBDDR = (unsigned int *)(start + 0x14); //port B direction
PEDR = (unsigned int *)(start + 0x20); //port E data
PEDDR = (unsigned int *)(start + 0x24); //port E direction
GPIOBDB = (unsigned int *)(start + 0xC4); // debounce on port B
GPIOADB = (unsigned int *)(start + 0xA8); // debounce on port b
*PADDR = 0x01; // PA0 as an output (for diode flashing)

*PBDDR = 0x00; //port B as an output
*PEDDR = 0x00; // port Eas an output

*PADR = ~0x01; //turn diode on

volatile float a=1;

for(int i=0;i<50000;i++) a+=0.01;//simple wait:)

*PADR = 0x01;// turn diode off

printf("program finished!") ;//show message

return 1;



}


No we should compile this application:

usr/local/arm/3.4/bin/arm-linux-g++ test.c -o test

As a result file test will be created. Now we can share this file by using
tftp serwer. If we use linux we can simply copy this file to /tftpboot
directory. Finally we can login to the ARM9 evaluation board. We will use
telnet protocol:

telnet xx.xx.xx.xx

where xx.xx.xx.xx is an IP adress of our evaluation board.

Now we can download our program to ARM board:


tftp -g -r test yyy.yyy.yyy.yyy

where yyy.yyy.yyy.yyy is an IP adress of our PC.

Now we can run our application. Make them executable:

chmod 777 test

and run:

./test

and we can see results.

Now operating system and our application are placed in RAM. When we turn off the power it is necessary to download application again. In next chapter we will show how to download the application and operating system directly into flash memory.

Last Updated on Sunday, 30 January 2011 21:55
 
Polish (Poland)English (United Kingdom)

Users online

We have 6 guests online
walkingrobots, Powered by Joomla!