deve
Newbie level 3
a simple c code like blinking a port or a pin doesn't work but the same code written in assembly works just fine.
I have used keil c51 compiler and sdcc as well but the code simply wont run.
This code works fine in other 8051 controllers.
I seriously cant figure this one out.:bang:
I have used keil c51 compiler and sdcc as well but the code simply wont run.
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 24 25 26 27 28 29 30 #include<reg2051.h> void delay(int n); //delay routine void delay(int n) { int i,j; for(i=0;i<=n;i++) { for(j=0;j<=1275;j++); //the loop will be occurring at n * 100 times } } void main( ) { P1=0x00; //Set port 1 to 0v logic P3=0x00; //Set port 3 to 0v logic while(1) { P1=0xAA; //set port 1 = 1. That is 00000001 on 8bit Port 1 delay(100); //Call delay routine to pause port 1 state P1 = 0x00; //set port 1 = 0. That is 00000000 on 8bit port 1 delay(100); // Call delay routine to pause port 1 state } }
This code works fine in other 8051 controllers.
I seriously cant figure this one out.:bang: