tomas
Member level 1
Hi, I was doing my project on real schematic, and after some time it stopped working.
So problem:
when I use these 2 codes it works:
and transmmiter:
but when I change receiver code to this:
it is not working? Where is the problem? What is wrong with this "if" statement? (as I mentioned, some time ago, if statements worked perfectly, also these codes works in proteus, but no longer in real scheme...) :shock:
So problem:
when I use these 2 codes it works:
Code:
void main() {
TRISD = 0x00;
PORTD = 0x00;
UART1_Init(2400);
while(1) {
if (UART1_Data_Ready() == 1) {
PORTD = ~UART1_Read();
Delay_ms(500);
}
}
}
and transmmiter:
Code:
void main() {
TRISB=0xFF;
PORTB=0x00;
UART1_Init(2400);
while(1) {
if (UART1_Tx_Idle() == 1) {
if (PORTB.RB0==1){
UART1_Write(0x01);
}
if (PORTB.RB1==1){
UART1_Write(0x02);
}
}
}
}
but when I change receiver code to this:
Code:
unsigned char receive=0;
void main() {
TRISD = 0x00;
PORTD = 0x00;
UART1_Init(2400);
while(1) {
if (UART1_Data_Ready() == 1) {
Delay_ms(100);
receive = ~UART1_Read();
Delay_ms(100);
if (receive == 0x01){
PORTD = ~UART1_Read();
Delay_ms(500);
}
}
}
}
it is not working? Where is the problem? What is wrong with this "if" statement? (as I mentioned, some time ago, if statements worked perfectly, also these codes works in proteus, but no longer in real scheme...) :shock: