Write from a pic18f to matlab
how would you write a pic program in picc18 compiler for a pic18f4431 in mplab to send the letters ‘G’ and 'A' to matlab at 9600 bps? All I can send with the code below is the letter 'K' a million times to matlab...
Thanks
#include <htc.h>
#include<pic18.h>
void delay()
{
for (int j=0;j<30000;j++)
{
}
}
void main(void)
{
//int i=0;
//BAUDCTLbits.BRG16=0;
//SPBRG = 0b01000000;
TXSTA =0x24; // TX enable BRGH=1
TRISC=0b10000000; // RX
RCSTA=0x90; // continuous RX
delay();
while(1)
{
TXREG = 'K';
delay();
wait:
if(TXIF==0 )
{
goto wait;
}
break;
}
}//END MAIN
Thanks
#include <htc.h>
#include<pic18.h>
void delay()
{
for (int j=0;j<30000;j++)
{
}
}
void main(void)
{
//int i=0;
//BAUDCTLbits.BRG16=0;
//SPBRG = 0b01000000;
TXSTA =0x24; // TX enable BRGH=1
TRISC=0b10000000; // RX
RCSTA=0x90; // continuous RX
delay();
while(1)
{
TXREG = 'K';
delay();
wait:
if(TXIF==0 )
{
goto wait;
}
break;
}
}//END MAIN
0