| ??? 08/24/05 05:28 Read: times Msg Score: -1 -1 Looks like homework |
#99942 - More encounters with Keil C51 |
(Hoping this is a new subject, so I am starting a new thread)
Hi all, just look into the following code:
/*globals*/
char packet[10];
unsigned char byte_no=0;
bit bdata txbit=0, rxbit=0, end_comm=0;
void serial(void) interrupt 4
{
if(TI) txbit=1;
if(RI)
{
rxbit=1;
comhandle();
}
}
void comhandle(void)
{
packet[byte_no]=SBUF;
byte_no++; //suspicion
if(byte_no==9)
{
byte_no=0;
end_comm=1;
}
}
void main(void)
{...}
What happens is that, the first byte of 10 byte serial packet never gets stored in packet[0]. What I suspect is, byte_no++ instruction gets evaluated in the first run, before the main function is called. So when a byte arrives, byte_no has value of 1. Will this happen? comhandle() function is supposed to run only when the microcont receives a serial byte. Any suggestions? Thanks and Regards, Vignesh |
| Topic | Author | Date |
| More encounters with Keil C51 | 01/01/70 00:00 | |
| Simulate it! | 01/01/70 00:00 | |
| It is not an homework | 01/01/70 00:00 | |
| Proving nothing. | 01/01/70 00:00 | |
| LCD | 01/01/70 00:00 | |
| Simulation Results | 01/01/70 00:00 | |
| Pointless | 01/01/70 00:00 | |
| Got it !! | 01/01/70 00:00 | |
| update | 01/01/70 00:00 | |
| do you set SCON as a byte or bitwise ? | 01/01/70 00:00 | |
| not an answer, but why do you call a fun | 01/01/70 00:00 | |
| I don't C | 01/01/70 00:00 | |
| inline | 01/01/70 00:00 | |
| Compiler Tries | 01/01/70 00:00 | |
| OT: inline, Keil ARM | 01/01/70 00:00 | |
C99 does specify inline as a keyword. | 01/01/70 00:00 | |
| Review index boundary value | 01/01/70 00:00 | |
| Even More Pointless simulation! | 01/01/70 00:00 |



