putch(unsigned char byte)
{
/* output one byte */
while(!TXIF) /* set when register is empty */
continue;
TXREG = byte;
}
printf("Apple\r\n");
Apple
Apple
111111
#include<pic.h>
#include<htc.h>
#include<conio.h>
#include<stdio.h>
__CONFIG(WDTDIS & INTIO & MCLRDIS);
#define XTAL_FREQ 8MHZ
void init_rs232();
#define MHZ *1000L
#define XTAL_FREQ 8MHZ
#define DelayUs(x) { unsigned char _dcnt; \
_dcnt = (x)/((12MHZ)/(XTAL_FREQ))|1; \
while(--_dcnt != 0) \
continue; }
void main()
{
OSCCON= 0x75; //8Mhz High Freq Clock, can be fine tuned using OSCTUNE
TRISE = 0x08;
TRISB = 0x00;
init_rs232();
while(1){
if(RE3==0){
RB0=1;
//printf("Apple\r\n");
putch('A');
putch('p');
putch('p');
putch('l');
putch('e');
}
else{
RB0=0;
if(TRMT){
TXREG = 49; // switch NOT pressed, 0x31/49 = 1
}
}
}
}
void init_rs232()
{
BRGH = 1;
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;
}
putch('A'); //Put A out to the UART buffer.
printf("%s\r\n", "Apple"); //Print "Apple" followed by CRLF out to the UART buffer.
while(1)
{
//Main loop
}
void Initialise_Bluetooth_Module()
{
DelayS(1);
putch('/');
putch('/');
putch('/');
DelayS(1);
}
//Master & Slave not set
AT*AGLN=TidyBluetooth,1
putchar(0x0D);
ATS2=47
ATS2=47
ATS2=47
putchar(0x0D);
ATE1
putchar(0x0D);
AT*AGDM=3,1
putchar(0x0D);
AT*AGCM=2,1
putchar(0x0D);
AT*AGPM=2,1
putchar(0x0D);
AT*AGB=bd_addr of the bt device to be bonded with
putchar(0x0D);
AT*AGND=bd_addr of the bt device to be retrieved from
putchar(0x0D);
AT*AGDD=1,(8*1.28)10.24
putchar(0x0D);
AT*AGI=2,2.56,5
putchar(0x0D);
AT*AGBD?
putchar(0x0D);
AT*AGFP=12te34ba,1
putchar(0x0D);
AT*ADDM
AT*ADDCP
AT*ADDSP
AT*ADNRP
AT*
bool m_Switched = false; //Global or main function variable.
if((RE3) && (!m_Switched))
{
m_Switched = true;
printf("Apple\r\n");
}
else if(!RE3)
{
m_Switched = false;
}
void init_rs232();
#define true 1
#define false 0
static bit m_Switched = false; //Global or main function variable.
if((RE3) && (!m_Switched))
{
m_Switched = true;
printf("Apple\r\n");
}
else if(!RE3)
{
m_Switched = false;
}
[/C0de] rly does help in the formatting? hmm, interesting...
anyways, this is the portion that i changed and the codes now look like,
[code]
#include<pic.h>
#include<htc.h>
#include<conio.h>
#include<stdio.h>
// __CONFIG(WDTDIS & INTIO & MCLRDIS);
#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; }
#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 = 0x00;
init_rs232();
//putch('B');
//printf("%s\r\n","Apple");
//while(1){
/* if(RE3==0){
RB0=1;
//printf("/// \r\n");
printf("%s\r\n","Apple");
putch('A');
putch('p');
putch('p');
putch('l');
putch('e');
// putStr("Apple");
// TXREG = 0x0D; carriage reutrn (\r)
// TXREG = 0x0A; new line feed (\n)
// if(TRMT){
TXREG = 0x41; //swtich pressed, send 0X41 = A
DelayUs(255);
TXREG = 0x70; //'p'
DelayUs(255);
TXREG = 0x70; //p
DelayUs(255);
TXREG = 0x6C; //l
DelayUs(255);
TXREG = 0x65; //e
DelayUs(255);
} //
}
else{
RB0=0;
if(TRMT){
TXREG = 49; // switch NOT pressed, 0x31/49 = 1
// while(TXIF==0); //wait until all bits are transmitted
}
}*/
static bit m_Switched = false; //Global or main function variable.
if((RE3) && (!m_Switched)) {
m_Switched = true;
printf("Apple\r\n");
} else if(!RE3) {
m_Switched = false; }
//}
}
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;
}
static bit m_Switched = false; //Global or main function variable.
if((!RE3) && (!m_Switched)) {
m_Switched = true;
printf("Apple \r\n");
} else if(RE3) {
m_Switched = false; }
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)
{
if (RA0) //&& (!m_Switched))
{
m_Switched = true;
RB0 = 1;
printf("Apple\r\n");
}
else if(!RA0)
{
m_Switched = false;
}
}
}
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?