We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
hi, i'm using a- 80c31 microcontroller to send the status of port bits: p3.3,p3.4,p3.5 using serial comm. my program works fine only in simulation and i cant get an idea where is the problem. i checked the TX pin(11) with a scope and it seems that no data are being sent.
please help...
#include <Reg51.h> sbit Input1 = 0xB3; /* P3.3 */ sbit Input2 = 0xB4; /* P3.4 */ sbit Input3 = 0xB5; /* P3.5 */ unsigned int Tmr1 = 0; unsigned int Tmr2 = 0; unsigned int Tmr3 = 0; void SendStatus() { if (Input1 == 0){ P2 = P2 | 0x03; Tmr1 = 0; } if (Input2 == 0){ P2 = P2 | 0x18; Tmr2 = 0; } if (Input3 == 0){ P2 = P2 | 0xC0; Tmr3 = 0; } TI = 0; SBUF = P2; while (TI == 0); /* Wait For Transmit */ if (TF0 == 1) { Tmr1 = Tmr1 + 1; Tmr2 = Tmr2 + 1; Tmr3 = Tmr3 + 1; if ((Tmr1>912)&&(Tmr2>912)&&(Tmr3>912)) { Tmr1 = 0; Tmr2 = 0; Tmr3 = 0; TR0 = 0; TF0 = 0; P2 = 0x00; } else if (Tmr1 == 912) {/* 60 Sec Alarm Hold*/ P2 = P2 & 0xFC; } else if (Tmr2 == 912) {/* 60 Sec Alarm Hold*/ P2 = P2 & 0xE7; } else if (Tmr3 == 912) {/* 60 Sec Alarm Hold*/ P2 = P2 & 0x3F; } else { TH0 = 0xFF; TL0 = 0xFF; TF0 = 0; } } } void main() { SCON = 0x40; /* 8-bit UART, BaudRate set by Timer-1 */ TMOD = 0x21; /* Timer1 mode 2, Timer-0 mode 1 */ TCON = 0x40; /* Start baud clock */ TR0 = 0; /* Turn Timer-0 off */ TH0 = 0xFF; TL0 = 0xFF; TF0 = 0; /* Clear rollover flag */ TR0 = 0; /* Turn timer-0 on */ TH1 = 0xCC; /* 600 baud 12MHz */ IE = 0x00; /* Disable serial int */ IP = 0x80; /* Interrupt priority stopped */ P2 = 0x00; P3 = 0x00; Input1 = 1; Input2 = 1; Input3 = 1; while(1) { while ((Input1 == 1)&&(Input2 == 1)&&(Input3 == 1)) { TI = 0; SBUF = 0x00; while (TI == 0);/* Wait For Transmit */ } TH0 = 0xFF; TL0 = 0xFF; TR0 = 1; /* Turn timer-0 on */ while (TR0 == 1) SendStatus(); } }
Hmm. Strange spelling for abominable...