Why code not working ?

Status
Not open for further replies.

milan.rajik

Banned
Joined
Apr 1, 2013
Messages
2,524
Helped
540
Reputation
1,078
Reaction score
524
Trophy points
1,393
Visit site
Activity points
0
Why code doesn't work as expected ?

This is my IAR EW ARM code for LPC2148. The LEDs 0n 0.4, 0.5, 0.6 and 0.7 turn ON but they don't turn OFF. I am new to ARM programming. I have written LED blink code in Keil uVision 5 for LPC2148 and it works fine but IAR code is not working.

Should I use IO0CLR = 0x00000000; ?


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include    <intrinsics.h>
#include    "iolpc2148.h"
 
void Delay() {
  
  unsigned long int i;
  
  for(i = 0; i < 4000; i++);
  
}
 
int main()
{
  IO0DIR = 0x000000F0;
 
  while(1) {
        
        IO0SET = 0x000000F0;
        Delay();
        IO0SET = 0x00000000;
        Delay();    
  }  
}

 

No. Did you ever tryed to read the manual? Possible, you do not understand how the BitBang technology works?
BitBang register are write only.
Write to SET register make output high. Write CLR makes low. BitBang allow us to use direct writing without read-modify-write methode. It takes only 2 cycles.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…