tntsei
Newbie level 2
- Joined
- Feb 4, 2015
- Messages
- 2
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 18
I everybody!!!
I'm new and my name it's Karim!!... Nice to meet you!!
I have a problem with my 8052 MCU and and I wanted to ask if you could give me some help!!!:-o
i Try to connect my 8052 MCU ( Aduc836 ) with one display touchscreen ( 4D systems uLCD 70 - DT) by serial TTL.
What i want to do for this moment it's always send a char ('a')when i push a button on the display and send thsi to my MCU....when the MCU receive the char, turn on one led, else if the the char receive it's wrong, turn on another led!!
The problem that i hacve it's that inside the SBUF register i have always in every case the value 0xFF and i can't understand why!!!!
Below the MCU code!!
if a modify the condition
with
The correct led it's turn on even though i send the value 'a'!!!!!
Any advice???? are quite distressed!!!
I'm new and my name it's Karim!!... Nice to meet you!!
I have a problem with my 8052 MCU and and I wanted to ask if you could give me some help!!!:-o
i Try to connect my 8052 MCU ( Aduc836 ) with one display touchscreen ( 4D systems uLCD 70 - DT) by serial TTL.
What i want to do for this moment it's always send a char ('a')when i push a button on the display and send thsi to my MCU....when the MCU receive the char, turn on one led, else if the the char receive it's wrong, turn on another led!!
The problem that i hacve it's that inside the SBUF register i have always in every case the value 0xFF and i can't understand why!!!!
Below the MCU code!!
Code:
#include <reg52.h>
sbit P3_4 = P3^4;
sbit P3_5 = P3^5;
void RecDat(void)
{
unsigned char dat;
RI = 0; // this is a flag set by hardware and cleared by software
dat = SBUF; // SBUF it's a 8 bit buffer that contains the 8 bit data received by uart
P2 = 0xFF; // i set ths port to this value to turn on the display
if( dat == 'a' )
{
P3_4 = 0; // turn on the correct led
P3_5 = 1; // turn off the wrong led
}
else
{
P3_4 = 1; // turn off the correct led
P3_5 = 0; // turn on the wrong led
}
}
void InitSerial(void) // Simply setting for UART and BaudRate MCU
{
TMOD |= 0x20; // Timer 1 in mode 2 (auto reload)
TL1 = 0xFD; // 9600 baud rate
TH1 = 0xFD;
SCON = 0x50; // Setup UART mode 2
TR1 = 1; // Start Timer1 and UART
}
void main (void) {
P2 = 0x00;
InitSerial();
while (1)
{
if (RI) { // if a receive the data by Serial RI it's setting by hardware to 1
RecDat ();
}
}
}
if a modify the condition
Code:
if( dat == 'a')
with
Code:
if( dat == 0xFF )
The correct led it's turn on even though i send the value 'a'!!!!!
Any advice???? are quite distressed!!!