Skip to content

Instantly share code, notes, and snippets.

@JHeld07
Created December 16, 2015 01:31
Show Gist options
  • Save JHeld07/ff7aa7a3cb55903191c7 to your computer and use it in GitHub Desktop.
Save JHeld07/ff7aa7a3cb55903191c7 to your computer and use it in GitHub Desktop.
//Trasmitter
#include <18f4520.h>
#use delay(clock=20000000)
#fuses HS, NOWDT, NOLVP
#include "../Library/18f4520ptr.h"
#include "../Library/modifiedlcd.h"
#INT_RDA // Interrupt for recieve data Only for USART Receive interupt Triggered by proper USART packet receive
void int_rda_isr(){
delay_ms(400); // Do not put delays in interupts
printf(lcd_putc, "\f %c", *RCREG);
*TXREG=*RCREG+1; // RCREG (8bits) is the receive register for the hardwired usart.
}
// RCREG = Data Receiver Register
// TXREG = Data Trasmit Register
main(){
char x='A';
lcd_init();
*TRISC-0x80;
TXSTA->TXEN=1; // Tx On
TXSTA->SYNC=0; // Asynch
TXSTA->BRGH=0; // Low Speed
RCSTA->SPEN=1; // Rx On RCSTA is setting up two interupts.
RCSTA->CREN=1; // Rx Cont. on
BAUDCON->BRG16=1; // Setting baud rate based off of table.
*SPBRG=129; // setting the interupt
PIE1->RCIE=1; // Rx Interupt Enable
// If Tx Enable is ON it wont work.
INTCON->GIE=1;
INTCON->PEIE=1;
*TXREG=x;
while(1){
//printf(lcd_putc, "\f hello");
// *TXREG='A';
// delay_ms(300);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment