jman
jman
Branch Unspecified
04 Dec 2008

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

Be the first one to reply

Share this content on your social channels -

Only logged in users can reply.