hi *waves* i am trying to get port values displayed over the rs232 i have the rs232 working
but not getting far with the c18 lib for usart i have the following code wich is messy at the mo as i am only testing stuff
how do i get it to print port values etc over the serial??
many thank yous its one the last parts for my bot ive never done serial before sorry
Code:
/*********************************************************************
* NOTES:
* Code uses the Peripheral library support available with MCC18 Compiler
* Code Tested on:
* PicDem2+ demo board with PIC18F4685 controller
*
* Uses Tx pin for transmission and Rx pin for reception.
* Baud rate of 19200 is configred at 8MHz oscillator fequency
**********************************************************************/
#pragma config OSC = IRCIO7, PWRT = OFF, WDT = OFF, MCLRE = ON, DEBUG = ON, LVP = OFF //..............Fuse stup
#define USE_OR_MASKS
#include <p18cxxx.h>
#include "usart.h"
unsigned char Rxdata[11];
unsigned char Txdata[] = " Test Connection ";
void main(void)
{
unsigned char config=0,spbrg=0,baudconfig=0,i=0;
Nop();
OSCCONbits.IRCF0=1;
OSCCONbits.IRCF1=1;
OSCCONbits.IRCF2=1;
OSCTUNEbits.PLLEN =1;
ADCON1=0x0A; //set up ADC
CMCON=0x07;
CloseUSART(); //turn off usart if was previously on
//-----configure USART -----
config = USART_TX_INT_OFF | USART_RX_INT_OFF | USART_ASYNCH_MODE | USART_EIGHT_BIT | USART_CONT_RX | USART_BRGH_HIGH;
//-----SPBRG needs to be changed depending upon oscillator frequency-------
spbrg = 207; //At 8Mhz of oscillator frequency & baud rate of 38400.
OpenUSART(config, spbrg); //API configures USART for desired parameters
baudconfig = BAUD_16_BIT_RATE | BAUD_AUTO_OFF;
baudUSART (baudconfig);
while(1)
{
Nop();
//------USART Transmission ----
baudUSART (baudconfig);
while(BusyUSART());
TXREG=PORTD;
WriteUSART( PORTD );
Nop(); //Check if Usart is busy or not
putsUSART((char *)Txdata ); //transmit the string
while(BusyUSART());
TXREG=PORTD;
Nop();
Nop();
WriteUSART( PORTD );
//---USART Reception ---
/* getsUSART((char *)Rxdata,24); //Recieve data upto 24 bytes
while(BusyUSART()); //Check if Usart is busy or not
putsUSART((char *)Rxdata); //echo back the data recieved back to host
// CloseUSART();
*/
// while(1); //end of program
}
}
how do i get it to print port values etc over the serial??
many thank yous its one the last parts for my bot ive never done serial before sorry