__CONFIG(WDTDIS & XT & MCLRDIS);
TXREG = 0x41; //sending 'A' when pressing switch, 0X41 = A
TXREG = 0x70; //p
TXREG = 0x70; //p
TXREG = 0x6C; //l
TXREG = 0x65; //e
if(!strcmp(inpBuff, m_OK_Response))
{
//OK Received
}
elseif(!strcmp(inpBuff, m_ERROR_Response))
{
//ERROR Received
}
else
{
//Unexpected Response
}
void init_rs232();
#define MHZ *1000L
#define XTAL_FREQ 4MHZ
#define DelayUs(x) { unsigned char _dcnt; \
_dcnt = (x)/((12MHZ)/(XTAL_FREQ))|1; \
while(--_dcnt != 0) \
continue; }
void main()
if(TRMT)
TXREG = 0x41; //sending 'A'
DelayUs(255);
DelayUs(255);
DelayUs(255);
DelayUs(255);
TXREG = 0x70; //sending 'p'
DelayUs(255);
DelayUs(255);
DelayUs(255);
DelayUs(255);
TXREG = 0x70; //p
DelayUs(255);
DelayUs(255);
DelayUs(255);
DelayUs(255);
TXREG = 0x6C; //l
DelayUs(255);
DelayUs(255);
DelayUs(255);
DelayUs(255);
TXREG = 0x65; //e
DelayUs(255);
DelayUs(255);
DelayUs(255);
DelayUs(255);
}
else{
RB0=0;
if(TRMT)
TXREG = 0x70; //sending 'p'
}
DelayUs(255);
//DelayUs(255);
DelayUs(255);
//DelayUs(255);
#define MHZ *1000L
#define XTAL_FREQ 4MHZ
#define DelayUs(x) { unsigned char _dcnt; \
_dcnt = (x)/((12MHZ)/(XTAL_FREQ))|1; \
while(--_dcnt != 0) \
continue; }
http://www.microchipc.com/sourcecode/#delay16x
http://www.edaboard.com/ftopic114099.html
__CONFIG(WDTDIS & INTIO & MCLRDIS);
#define XTAL_FREQ 8MHZ
void main()
{
OSCCON = 0x75; //NEW LINE, 8MHz High Frequency clock
TRISE = 0x08;
TRISB = 0x00;
init_rs232();
FOSC/[4 (n+1)]
FOSC = 4MHz = 4000000
400000 / 57600 (Desired Baud Rate) / 4 - 1 = 16.36 = 16
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?