#include<pic.h>
#include<htc.h>
#include<conio.h>
#include<stdio.h>
#define XTAL_FREQ 8MHZ
void init_rs232();
//void putChar( unsigned char ch);
#define MHZ *1000L
#define XTAL_FREQ 8MHZ
#define DelayUs(x) { unsigned char _dcnt; \
_dcnt = (x)/((12MHZ)/(XTAL_FREQ))|1; \
while(--_dcnt != 0) \
continue; }
int m_Count;
//m_Count=0;
#define true 1
#define false 0
void main()
{
//TRISC = 0b10000000; no need to set TRISC as its the lowest priority if we've already set the TXEN, etc
OSCCON= 0x75; //8Mhz High Freq Clock, can be fine tuned using OSCTUNE
TRISE = 0x08;
TRISB = 0xF0;
ADCON1 = 0x07;
init_rs232();
static bit m_Switched = false;
while(1){
//Global or main function variable.
if((!RE3) && (!m_Switched))
{ m_Switched = true;
/* ??? //m_Count=0
m_Count++;
switch(m_Count){
case 1:
RB0 = 1;
printf("/// \r\n\0"); // AT mode
break;
case 2:
RB1=1;
printf("AT*AGND \r\n\0"); // search fr new device
break;
case 3:
RB0=1;
RB1=1;
break; }
}*/
if (RB0==0) {
RB0 = 1;
printf("/// \r\n\0"); } //goes into AT mode
} else if((RE3) && (m_Switched))
{ m_Switched = false;
RB0 = 0;
}
/* //int click=0;
switch(!RE3){
case1:
PORTB=0b00000001;
printf("/// \r\n\0");
} */
}
}
void init_rs232()
{
BRGH = 1; // high baud rate to avoid baud rate error & bcos 16bit achieve slow baud rates fr fast osc freq
BRG16 = 0;
SPBRG = 8; // Fosc=8Mhz, ,16, BR=57600
TX9 = 0; // 9bits=1: 8-bit=0
SYNC = 0; // asynchronous
SPEN = 1; // enable serial port pins
TXEN = 1; // enable the transmitter & (automatically)TXIF=1
CREN = 1; // enable reception
SREN = 0; // no effect
TXIE = 0; // disable tx interrupts
RCIE = 0; // disable rx interrupts
RX9 = 0; // ninebits?1:0,,,8- or 9-bit reception
}
void putch(unsigned char byte)
{ /* output one byte */
while(!TXIF) /* set when register is empty */
continue;
TXREG = byte;
}
unsigned char getch()
{ /* retrieve one byte */
while(!RCIF) /* set when register is not empty */
continue;
return RCREG;
}
unsigned char getche(void)
{ /*echo @ HT*/
unsigned char c;
putch(c = getch());
return c;
}
int m_Count = 0;
void getche(unsigned char c)
if((!RE3) && (!m_Switched))
{ m_Switched = true;
m_Count++;
switch(m_Count){
case 1:
RB0 = 1;
printf("/// \r\n\0"); // AT mode
break;
case 2:
RB1=1;
printf("AT*AGND \r\n\0"); // search fr new device
break;
case 3:
RB0=1;
RB1=1;
break; }
}
#include<pic.h>
#include<htc.h>
#include<conio.h>
#include<stdio.h>
#define MHZ *1000L
#define XTAL_FREQ 8MHZ
#define DelayUs(x) { unsigned char _dcnt; \
_dcnt = (x)/((12MHZ)/(XTAL_FREQ))|1; \
while(--_dcnt != 0) \
continue; }
void init_rs232();
//void putChar( unsigned char ch);
//void getche (unsigned char c);
int m_Count=0;
#define true 1
#define false 0
void main()
{
OSCCON= 0x75; //8Mhz High Freq Clock, fine tuned using OSCTUNE
TRISE = 0x08;
TRISB = 0xF0;
ADCON1 = 0x07;
init_rs232();
static bit m_Switched = false;
while(1){
getch();
getche();
//Global or main function variable.
if((!RE3) && (!m_Switched))
{ m_Switched = true;
/* m_Count++;
switch(m_Count){
case 1:
RB0 = 1;
printf("/// \r\n\0"); // AT mode
break;
case 2:
RB1=1;
printf("AT*AGND \r\n\0"); // search fr new device
break;
case 3:
RB0=1;
RB1=1;
break; }
}*/
if (!RB0) {
RB0 = 1;
printf("/// \r\n\0"); } // should go into AT mode
} else if((RE3) && (m_Switched))
{ m_Switched = false;
RB0 = 0;
}
}
}
void init_rs232()
{
BRGH = 1; // high baud rate to avoid baud rate error & bcos 16bit achieve slow baud rates fr fast osc freq
BRG16 = 0;
SPBRG = 8; // Fosc=8Mhz, ,16, BR=57600
TX9 = 0; // 9bits=1: 8-bit=0
SYNC = 0; // asynchronous
SPEN = 1; // enable serial port pins
TXEN = 1; // enable the transmitter & (automatically)TXIF=1
CREN = 1; // enable reception
SREN = 0; // no effect
TXIE = 0; // disable tx interrupts
RCIE = 0; // disable rx interrupts
RX9 = 0; // ninebits?1:0,,,8- or 9-bit reception
}
void putch(unsigned char byte)
{ /* output one byte */
while(!TXIF) /* set when register is empty */
continue;
TXREG = byte;
}
unsigned char getch()
{ /* retrieve one byte */
while(!RCIF) /* set when register is not empty */
continue;
return RCREG;
}
unsigned char getche(void)
{ /*echo @ HT*/
unsigned char c;
putch(c = getch());
return c;
}
while(1)
{
getche();
}
void main()
{
OSCCON= 0x75; //8Mhz High Freq Clock, fine tuned using OSCTUNE
TRISE = 0x08;
TRISB = 0xF0;
ADCON1 = 0x07;
init_rs232();
static bit m_Switched = false;
while(1){
getche();
//Global or main function variable.
if((!RE3) && (!m_Switched))
{ m_Switched = true;
/* m_Count++;
switch(m_Count){
case 1:
RB0 = 1;
printf("/// \r\n\0"); // AT mode
break;
case 2:
RB1=1;
printf("AT*AGND \r\n\0"); // search fr new device
break;
case 3:
RB0=1;
RB1=1;
break; }
}*/
if (!RB0) {
RB0 = 1;
printf("/// \r\n\0"); } // should go into AT mode
} else if((RE3) && (m_Switched))
{ m_Switched = false;
RB0 = 0;
}
}
}
while(1)
{
printf("ATI\r\n");
getche();
}
#include<pic.h>
#include<htc.h>
#include<conio.h>
#include<stdio.h>
__CONFIG(WDTDIS & INTIO & MCLRDIS);
void init_rs232();
#define true 1
#define false 0
void main()
{
OSCCON = 0x75;
TRISA0 = 1;
TRISB = 0x00;
init_rs232();
static bit m_Switched = false; //Global or main function variable.
while(1)
{
getche();
/* if (RA0) //&& (!m_Switched))
{
m_Switched = true;
RB0 = 1;
printf("Apple\r\n");
}
else if(!RA0)
{
m_Switched = false;
}*/
}
}
void init_rs232()
{
BRGH = 1;
BRG16 = 0;
SPBRG = 51; /* set baud rate: Fosc=8Mhz, 16, BR=9600 */
TX9 = 0; /* ninebits?1:0,,,8- or 9-bit transmission */
SYNC = 0; /* asynchronous */
SPEN = 1; /* enable serial port pins */
TXEN = 1; /* enable the transmitter & (automatically)TXIF=1 */
CREN = 1; /* enable reception */
SREN = 0; /* no effect */
TXIE = 0; /* disable tx interrupts */
RCIE = 0; /* disable rx interrupts */
}
void putch(unsigned char byte)
{
/* output one byte */
while(!TXIF) /* set when register is empty */
continue;
TXREG = byte;
}
unsigned char getch() {
/* retrieve one byte */
while(!RCIF) /* set when register is not empty */
continue;
return RCREG;
}
unsigned char getche(void)
{
unsigned char c;
putch(c = getch());
return c;
while(1)
{
printf("ATI\r\n");
getche();
}
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?