I've no clue what im doing wrong while trying to get this work everything is correctly connected, RX output is sending signal and the TX port is receiving checked it with oscilloscope.
Im using TX433 and RX433 modules, c18 code. Am I doing something wrong when receiving data? Cuz thats the only thing that can cross my mind at this moment.
When i check RX&TX ports on oscilloscope they are having the same structure except that TX port has a ppv 400mV and RX ppv 2V or something around there. Can that be a problem for the circuit.
Sender
Receiver
Any help or idees are appreciated!
Im using TX433 and RX433 modules, c18 code. Am I doing something wrong when receiving data? Cuz thats the only thing that can cross my mind at this moment.
When i check RX&TX ports on oscilloscope they are having the same structure except that TX port has a ppv 400mV and RX ppv 2V or something around there. Can that be a problem for the circuit.
Sender
Code:
#include <p18f2550.h>
#define test 0x30
#define test 0x31
void send_data(char data);
void UART(void);
void delay_ms(int sec);
void UART(void)
{
TXSTA = 0x20; // low baud-rate & 8bit
SPBRG = 155; // 1200 baud rate & XTAL = 12MHz
SPBRGH = 0;
TRISCbits.TRISC6 = 0;
TXSTAbits.TXEN = 1; // TX port!
RCSTAbits.SPEN = 1; // enable entire serial port of PIC18
RCSTAbits.CREN = 1;
TXREG=0x00; // Dummy send
// BAUDCON = 0x10
}
void send_data(char data)
{
while(PIR1bits.TXIF==0); // wait until all sent
TXREG = data; // send data
}
void delay_ms(int sec) // 50ms delay
{
int i;
for(i=0;i<sec;i++)
{
T0CON=0b00000000;
TMR0L=0x85;
TMR0H=0xEE;
T0CONbits.TMR0ON=1;
while(INTCONbits.TMR0IF==0);
T0CONbits.TMR0ON=0;
INTCONbits.TMR0IF=0;
}
}
void main(void)
{
UART();
while(1)
{
send_data(test);
delay_ms(6000);
send_data(test2);
}
}
Receiver
Code:
#include <p18f4550.h>
#include "lcdlib.h" // #include USART is an option
void main_init(void);
void RC_ISR(void);
void delay_ms(int sec);
void chk_isr(void);
#pragma code My_HiPrio_Int=0x08 // high prio
void My_HiPrio_Int(void)
{
_asm
GOTO chk_isr
_endasm
}
#pragma code
#pragma interrupt chk_isr
void chk_isr(void)
{
if(PIR1bits.RCIF == 1) // recive interrupt
{
RC_ISR();
}
}
void main_init(void)
{
TXSTA = 0x20;
RCSTA = 0x90; // enable serial & receiver, check notes
SPBRG = 255; // 9600 baud rate / XTAL = 20MHz
SPBRGH = 0; // can be skipped?
TRISCbits.TRISC7 = 1; // rx input
TRISCbits.TRISC6 = 0;
TXSTAbits.TXEN = 1;
RCSTAbits.CREN = 1;
RCSTAbits.SPEN = 1;
PIE1bits.TXIE = 1;
PIE1bits.RCIE = 1; // recive interrupt
INTCONbits.PEIE = 1; //peripheral intrrupt
INTCONbits.GIE = 1; // all interrupts
// BAUDCON 0x20
}
void RC_ISR(void)
{
char indata; // DATASHEET *
indata = RCREG; // 9. Read the 8-bit received data
commd(LINE_1); // RCREG register.
prnts(indata);
}
void delay_ms(int sec) // delay 50ms * x
{
int i;
for(i=0;i<sec;i++)
{
T0CON=0b00000000;
TMR0L=0x85;
TMR0H=0xEE;
T0CONbits.TMR0ON=1;
while(INTCONbits.TMR0IF==0);
T0CONbits.TMR0ON=0;
INTCONbits.TMR0IF=0;
}
}
void main(void)
{
char klar[] = "klar";
lcd_init();
main_init();
commd(LINE_2);
prnts(klar);
while(1){
delay_ms(1500);
}
}
Any help or idees are appreciated!