Пример #1
0
void Init44k22(void)
{
//OSC int 16MHz (62.5ns/inst.)
OSCCONbits.IRCF2 = 1;
OSCCONbits.IRCF1 = 1;
OSCCONbits.IRCF0 = 1;
while(!OSCCONbits.HFIOFS); //wait until ready

//Uart1
ANSELCbits.ANSC7 = 0; //Port C7 select som digital port
ANSELCbits.ANSC6 = 0; //Port C6 select som digital port

//Uart2
ANSELDbits.ANSD7 = 0; //Port D7 select som digital port
ANSELDbits.ANSD6 = 0; //Port D6 select som digital port

//Leds
ANSELAbits.ANSA3 = 0; //Port A3 select som digital port Red
ANSELEbits.ANSE1 = 0; //Port E1 select som digital port Green
ANSELEbits.ANSE2 = 0; //Port E2 select som digital port Blue

//InitTimer0();
InitTimer1();
//InitTimer2();
InitTimer3();

InitUart1();
InitUart2();

Init_IO();
}
Пример #2
0
int do_interface(void)
{
    int i = 0;
    int pcm = 0;
    int pno = 0;
    int recv_length = 0;
    float val = 0;
    unsigned char buf[128];

    InitUart2(9600);
    //InitUart2(115200);

    while(1)
    {
        SendUart2("123456789012345678901234", 20);
        recv_length = RecvUart2(buf, 128);
        pset(1, 1, 1);
        sleep(1);
        //SendUart2("test uart2", 10);
        SendUart2("123456789012345678901234", 20);
        recv_length = RecvUart2(buf, 128);
        pset(1, 2, 1);
        sleep(1);
        //SendUart2("test uart2", 10);
        SendUart2("123456789012345678901234", 20);
        recv_length = RecvUart2(buf, 128);
        pset(1, 3, 1);
        sleep(1);
        //SendUart2("test uart2", 10);
        SendUart2("123456789012345678901234", 20);
        recv_length = RecvUart2(buf, 128);
        pset(1, 4, 1);
        sleep(1);
    }

    val = pget(1, 1);
    printf("val = %f\n", val);
    val = pget(1, 2);
    printf("val = %f\n", val);
    val = pget(1, 3);
    printf("val = %f\n", val);
    val = pget(1, 4);
    printf("val = %f\n", val);

    printf("short = %d\n", sizeof(unsigned short));
}