EQuestionAnswers.com Computer/Electronics Questions and Answers
C, C++, VC++, COM/DCOM, DLL and more
#Login #Sign up  Facebook Twitter TGoogle+

#Previous Topic #Index #Next Topic

This code is an addon patch on 2440test project. 2440test is a C based project provide my FriendlyARM DVD. ARM Developer Studio is needed to compile and build this project and binary can be loaded to Mini2440 via JTAG. This change is needed in main.c. We are enabling and setting CLK0 pin clock pin and connecting this to PCLK. We are also setting GPIOA 13 pin as Address chip select pin for the address 0x10000000. Next is basically a loop where we are waiting for 1s and toggling LED status. We are first reading the status in a byte. Then toggling LSB bit. Then again writing the state back to device.

static void __irq Isr_INT3(void)
  Uart_Printf("Int EINT3 on read/write at 0x10000000\n");
void Isr_Init(void)
  pISR_SWI  =(unsigned)HaltSwi;
10    pISR_PABORT=(unsigned)HaltPabort;
11    pISR_DABORT=(unsigned)HaltDabort;
12    rINTMOD=0x0;    /* All=IRQ mode */
13    rINTMSK=BIT_ALLMSK;    /* All interrupt is masked. */
15    pISR_EINT3 = (unsigned)Isr_INT3;
16    ClearPending(BIT_EINT3);
17    rINTMSK =~(BIT_EINT3);
18  }
21  void Main(void)
22  {
23    unsigned char val;
25    Clk0_Enable(4);  /* 4:PCLK */
26    Clk1_Disable();
27    rGPACON |= (<< 13);
30    while(1)
31    {
32      Delay(1000);
33      val =  *((unsigned char*)0x10000000);
34      val ^= 1;
35      *(char*)0x10000000 = val;
36    }
37    /* Or without val */
38    while(1)
39    {
40      Delay(1000);
41      *(char*)0x10000000 ^= 1;
42    }
43  }

This is the disassembly of the C code

val =  *((unsigned char*)0x10000000);
val ^= 1;
*(char*)0x10000000 = val;
[0xe3a00540] * mov      r0,#0x10000000
[0xe5d06000]   ldrb     r6,[r0,#0]
[0xe2266001]   eor      r6,r6,#1
[0xe3a00540]   mov      r0,#0x10000000
[0xe5c06000]   strb     r6,[r0,#0]

Output: LED will turn on or off as per val 0 bit. Interrupt will be triggred

You have viewed 1 page out of 14. Your learning is 0.00% complete. Login to check your learning progress.

 Vote 0

Similar topics related to this section

Altera FPGA interfacing ARM, ARM CPU internals, ARM CPU, Cache Memory and MMU, ARM bus hierarchy, ARM data, address and control lines, ARM MMIO read, ARM MMIO write, FPGA interfacing with system bus, VHDL/Verilog program, ADS C Code, Linux Direct MMIO App, Linux Device Driver, Linux Application code, Final Demo,

* #1 webmaster Tue 15 Apr/2014 04:44:38(GMT)  Like 0 Unlike 0

Dear Users,

We are pleased to inform you that a forum/blog has been incorporated with www.equestionanswers.com. You are welcomed to add your comments, requests, codes, solutions and feedback to it. Please login(if already a member) or signup(for free) to avail to this facility.


Your message goes here:

My Post:*
Secutiry Code: ******  *
Preview this compose before posting this in discussion forum.
  1. Use [Sxx] code to show smiles. Example [S02]
  2. Use [URL ], example [URL http://www.google.com/]
  3. To display code or un formatted text use [CODE] [/CODE]. Example: [CODE] printf("Hello world"); [/CODE]
 [S01]   [S02]   [S03]   [S04]   [S05]   [S06]   [S07]   [S08] 
 [S09]   [S10]   [S11]   [S12]   [S13]   [S14]   [S15]   [S16] 
 [S17]   [S18]   [S19]   [S20]   [S21]   [S22]   [S23]   [S24] 

Note: Only members are allowed, * fields are mandatory.