??? 02/02/06 14:26 Read: times |
#108976 - c code failure |
Hello everyone, I'm learning to program my 8051 in C. I´ve tryied handleing serial interruptions but I failed.
what I expected is that onced entered the infinite loop, if it recieves a byte then it should call the serial interruption and echo the byte. I will apreciate any kind of help, thanks. Here is the code... /*------------------------------------------------ includes ------------------------------------------------*/ #include <stdio.h> #include <reg52.h> /*------------------------------------------------ declarations ------------------------------------------------*/ void serialini (void); void serialint (void); /*------------------------------------------------ The main C function. Program execution starts here after stack initialization. ------------------------------------------------*/ void main (void) { serialini(); /*Inicialize serial */ printf ("Hello World\n"); /*Print "Hello World" */ while(1); /* infinite loop */ } /*------------------------------------------------ Setup the serial port for 9600 baud at 11.0592MHz. ------------------------------------------------*/ void serialini (void){ SCON = 0x50; /*SCON: mode 1, 8-bit UART, enable rcvr*/ TMOD |= 0x20; /*TMOD: timer 1, mode 2, 8-bit reload */ TH1 = 0xfd; /*TH1 reload value for 9600 baud */ TL1 = 0xfd; /*TL1 reload value for 9600 baud */ TR1 = 1; /*TR1: timer 1 run */ TI = 1; /*TI: set TI to send first char of UART*/ } /*------------------------------------------------ Serial interruption, echoes the incoming byte ------------------------------------------------*/ void serialint (void) interrupt 4 { putchar(getchar()); } |
Topic | Author | Date |
c code failure | 01/01/70 00:00 | |
comments | 01/01/70 00:00 | |
Thanks Erik | 01/01/70 00:00 | |
what the hell is wrong here? | 01/01/70 00:00 | |
Debugging | 01/01/70 00:00 | |
what about tools ur using | 01/01/70 00:00 | |
resistor micro ???? | 01/01/70 00:00 | |
that was just to know | 01/01/70 00:00 | |
areb you getting nothing | 01/01/70 00:00 | |
Keil / AT89S8252 | 01/01/70 00:00 | |
What is wrong here? | 01/01/70 00:00 | |
Absolutely!!! | 01/01/70 00:00 | |
Thanks![]() | 01/01/70 00:00 |