Hi, I'm using the C51 compiler and running the SIO sample projects with an AT89s52 atmel microcontroller. The code compiles fine and I've run various simple I/O and timer programs successfully. When I tried to generate my own program that integarate pieces from various projects I found that I don't get any serial data out of the TX pin when using the code from the SIO and SIO2 examples.
I then tried only using the example projects and I don't get any output from those samples either. I'm viewing the output with a scope and I don't see any changes on the I/O line. The pin is floating so there isn't any possibility of some external circuit affecting the output. The datasheet states that Port3 has internal pullups so I don't expect I need any type of interface components to simply see the serial data.
Any idea what might be inhibiting the output? I'm new with the 8051 controllers so I expect its a simply problem.
I'm using a 12Mhz crystal with my hardware. Any suggestions would be appreciated.
-- Dan
.
in sio.c, pasted below:
static void com_isr (void) interrupt 4 using 2 { /*------------------------------------------------ Received data interrupt. ------------------------------------------------*/ if (RI != 0) { RI = 0; if ((r_in + 1) != r_out) rbuf [r_in++] = SBUF; } /*------------------------------------------------ Transmitted data interrupt. ------------------------------------------------*/ if (TI != 0) { TI = 0; if (t_in != t_out) SBUF = tbuf [t_out++]; else t_disabled = 1; } }
the only action to these variables in your shown code (you hid the ISR are you hiding more) is twice
t_in = 0; t_out = 0;
in sio.c (whereever you got it, whatever it is) you find
if (t_in != t_out) SBUF = tbuf [t_out++];
since t_in != t_out never is true, you will, of course, not get any output
Erik
There are more issues.
The code does a t_out++.
No turn-around when it reaches the end of the buffer, or modulo operation in case the index is allowed to run the full length of the data type (I'm assuming an unsigned data type).
There is nothing wrong with good, honest, debugging. Anyone who does spend time with code, setting breakpoints, single-stepping and looking at the code, will quickly notice when things starts to deviate from what was planned.
And the really good thing here is the availability of a simulator. So it is way easier to debug than when running on real, live, hardware where all stimuli are arriving at full speed even when the processor is stopped at a breakpoint.
As I said before, the forum doesn't let me post the entire code so no I'm not HIDING anything. Also as I mentioned, this is not my code but a Keil example that apparently doesn't work. I am new to Keil and the 8051 so I was hoping to have a working example to evaluate. I am quite capable of debugging my own code, I simply thought someone here had run through the example code and could point out why an example provided by KEIL might not be working.
I'll evaluate some other compiler since Keil can't provide working examples so I can only imagine how good the compiler itself is.
I'm done here
-- dan
The five your old tantrum.
This forum isn't handled by Keil support staff but other Keil users.
So why are we here? Most probably because we have not found the Keil compilers to be lousy...
in your first post The code compiles fine and I've run various simple I/O and timer programs successfully
now suddenly but a Keil example that apparently doesn't work
could it possibly - I know the chance is infitessimally small - be your fault in When I tried to generate my own program that integarate pieces from various projects I found that I don't get any serial data out of the TX pin when using the code from the SIO and SIO2 examples.