imranahmed
Advanced Member level 3
- Joined
- Dec 4, 2011
- Messages
- 817
- Helped
- 3
- Reputation
- 6
- Reaction score
- 3
- Trophy points
- 1,298
- Location
- Karachi,Pakistan
- Activity points
- 6,493
Please let me know I programmed a two PIC16F877A one is Tx and other is Rx but not doing good transferring of data to receiver. I checked both PIC16F877A with sample LED blinking code they both are working. PIC16F877A does not have internal oscillator I used 8Mhz Crystal with 15pF Capacitors. I am using Mikro C Pro for PIC compiler and using UART module. I check both Tx and Rx RF module both working good on Arduino but I want to make them work with PIC16F877A.
PicKit 3 Programmer used.
Receiver Code:
Transmitter Code:
PicKit 3 Programmer used.
Receiver Code:
Code:
#define _XTAL_FREQ 8000000 //Crystal Frequency, used in delay
unsigned char uart_rd;
void main() {
UART1_Init(9600); // Initialize UART module at 9600 bps
TRISD2_bit = 0;
PORTD.RD2 = 0;
while(1){
if (UART1_Data_Ready()) { // If data is received,
uart_rd = UART1_Read(); // read the received data,
if(uart_rd == 0x1E){
PORTD.RD2 = 1;
}
if(uart_rd == 0x1A){
PORTD.RD2 = 0;
}
}
}
}
Transmitter Code:
Code:
#define _XTAL_FREQ 8000000 //Crystal Frequency, used in delay
unsigned char uart_rd;
void main() {
UART1_Init(9600); // Initialize UART module at 9600 bps
TRISD2_bit = 1;
while(1){
if (Button(&PORTD, 2, 1, 1)) { // Detect logical one
UART1_Write(0x1A);
}else if(Button(&PORTD, 2, 1, 0)) {
UART1_Write(0x1E);
}
}
}