Help with Keil!!!
Discussion in "General help Guidance and Discussion" started by Amit Radha Feb 10, 2008.
Sun Feb 10 2008, 11:12 pm
Facing trouble with coding in c. I am farely good in assembley but am trying to sharpen my c skills for 8051. I am trying to toggle P0. No matter what I try, only P0is toggling but the Pins dont toggle. They remain as 0000000 only. Pls correct me. This is one of the codes i tried. Wat is the difference can u explain and wil it have any impact while using such a code physically in a microcontroller?
#include<reg51.h>
void main(void)
{
unsigned int x;
for(x=0;x<10;x++)
{
// for(y=0;y<10000;y++)
P0=0x00;
// for(y=0;y<10000;y++)
P0=0xff;
}
}
Also I am encountering an error at the completeion of al my codes(in assembley and c)
"error 65: access violation at C:0x.... : 'execute/read' permission"
(i have used .... to indicate that different values are shown here for differnt codes i have tried)
Thanks
#include<reg51.h>
void main(void)
{
unsigned int x;
for(x=0;x<10;x++)
{
// for(y=0;y<10000;y++)
P0=0x00;
// for(y=0;y<10000;y++)
P0=0xff;
}
}
Also I am encountering an error at the completeion of al my codes(in assembley and c)
"error 65: access violation at C:0x.... : 'execute/read' permission"
(i have used .... to indicate that different values are shown here for differnt codes i have tried)
Thanks
Mon Feb 11 2008, 01:31 am
please correct and try..
also didnt get what u mean by
for the error part ...
try by not passing any argument to main fun...
ex. use void main() ....
for(x=0;x<10;x++) { // for(y=0;y<10000;y++) P0=0x00; // for(y=0;y<10000;y++) P0=0xff; }
unsigned int y; for(x=0;x<10;x++) { for(y=0;y<10000;y++); P0=0x00; for(y=0;y<10000;y++); P0=0xff; }
also didnt get what u mean by
No matter what I try, only P0is toggling but the Pins dont toggle
for the error part ...
try by not passing any argument to main fun...
ex. use void main() ....
[ Edited Mon Feb 11 2008, 01:33 am ]
Mon Feb 11 2008, 07:28 pm
Hi Shyam,
1. I tried it with void main() but i stil got the access violation error after al the instructions were executed.
2. I am not using for(y=0;y<10000;y++); because i am debugging it and doing "step" to see the result of each instruction. (such a huge delay will take me ages!!!)
3. By the P0 toggling and Pins not toggling I mean that when u open the peripheral window to check the P0 value it shows P0 and Pins.
Il upload the screenshot to show you.
1. I tried it with void main() but i stil got the access violation error after al the instructions were executed.
2. I am not using for(y=0;y<10000;y++); because i am debugging it and doing "step" to see the result of each instruction. (such a huge delay will take me ages!!!)
3. By the P0 toggling and Pins not toggling I mean that when u open the peripheral window to check the P0 value it shows P0 and Pins.
Il upload the screenshot to show you.
[ Edited Mon Feb 11 2008, 09:34 pm ]
Mon Feb 11 2008, 09:40 pm
you forgot to add one statement in your code..
after editing your code, do not forget to recompile it.
while (1){ //your for loop here :) }
after editing your code, do not forget to recompile it.
Mon Feb 11 2008, 10:13 pm
Hi ajay,
That solves the prolem of that access violation error. Thanks.
But wat do i do for the no change in "Pins" value which remains null ater the 1st time it is reset. as u can see in my screenshot?
And any help on my sensor problem? shall i start another thread for that?
That solves the prolem of that access violation error. Thanks.
But wat do i do for the no change in "Pins" value which remains null ater the 1st time it is reset. as u can see in my screenshot?
And any help on my sensor problem? shall i start another thread for that?
Mon Feb 11 2008, 10:47 pm
Pins value wont change because.. Pins are actually for input. you should not forget that you are using a debugger. So when you write something to port it goes to P0 not to pins. when you want to enter something to port then you have enter value through pins thats why they have given both pins and port register differently.
I don't know how to explain this question has got a logical answer.
I don't know how to explain this question has got a logical answer.
Amit Radha like this.
Powered by e107 Forum System