HI all together
first: sorry for my bad english, i hpe i can explain my problem good enough...
I try to send some data to the serrial port. ive take an example from a book and make some changes.
here is the code i use:
#include <reg167.h> #include <stdio.h> sbit SerrielPin = P3^10; unsigned int reciv(void) { while (!S0RIR); S0RIR = 0; return S0RBUF; } void send (unsigned int zeichen) { while(!S0TIR) S0TIR = 0; S0TBUF = zeichen; } int main(void) { unsigned int x; DP3 |= 0x0400; DP3 &= 0xF7FF; SerriellPin = 1; S0TIC = 0x0080; S0RIC = 0x0000; S0BG = 64; S0CON = 0x8011; //this is the Problem while(1) { send(10); send(13); send('H'); } do { x = reciv(); send(x); } while (x != 0x1b); return 0; }
Ok, normaly this is only an echo, i tryed to send some data after another. And this doesnt work!!! If i tryed it without the first while statement, onle the first and the last "sign" will be send. With this while statement it will go complete crazy! Sometimes only the last "sign" will be send sometimes all "signs" will be send in a crazy order... very difficult to explain...
the "printf()" statement doesnt work at all...
can anybody help me an tell me where is my mistake?
it would be very nice. thanks a lot Stephan