CrazyEngineers
  • jman
    jman

    MemberDec 3, 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
    #include

    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
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Home Channels Search Login Register