Settings.inc and user.inc attached. The code sets up the clock at 48MHz ready for USB usage and should also work on the 16F1454. For use on the 16F1459 you will need to set ANSELB to zero in user.inc
A trivial change is needed to uart.inc to change label for SPBRGL to SPBRG as below:
A trivial change is needed to uart.inc to change label for SPBRGL to SPBRG as below:
Code:
ifndef USE_UART1
ifndef USE_UART2
error "No communication is specified"
endif
endif
ifdef USE_UART1
ifdef USE_UART2
error "Both uarts are specified"
endif
#define PIRRCIF_ PIR1 ;uart interupt status register
#define RCIF_ RCIF
ifdef TX1STA
#define TXSTA_ TX1STA ;uart status
#define RCSTA_ RC1STA ;uart status
#define SPBRG_ SP1BRGL ;uart baudrate
#define SPBRGH_ SP1BRGH ;uart baudrate
#define TXREG_ TX1REG ;uart transmit
#define RCREG_ RC1REG ;uart receive
#define BAUDCON_ BAUD1CON ;uart receive
else
#define TXSTA_ TXSTA ;uart status
#define RCSTA_ RCSTA ;uart status
#ifndef SPBRG
#define SPBRG_ SPBRGL ;uart baudrate
#else
#define SPBRG_ SPBRG ;uart baudrate
#endif
#define SPBRGH_ SPBRGH ;uart baudrate
#define TXREG_ TXREG ;uart transmit
#define RCREG_ RCREG ;uart receive
ifdef BAUDCON
#define BAUDCON_ BAUDCON ;uart receive
else
#define BAUDCON_ BAUDCTL ;uart receive
endif
endif
endif