chipKIT® Development Platform

Inspired by Arduino™

CEREBOT MX7cK UART

Created Mon, 06 May 2013 13:42:46 +0000 by cerebot_fontys


cerebot_fontys

Mon, 06 May 2013 13:42:46 +0000

Hello, I am working with a cerebot MX7cK and MPLAB X.

I wanted to set the Uart-Communication with Interrupts. I setted it up according to the PIC32Reference, but i can't clear the Interrupt flag.

UART-Initialization:

void init_uart()
{
    IEC0bits.U1TXIE = 0;
    IEC0bits.U1RXIE = 0;
    IEC0bits.U1EIE  = 0;
    
    IFS0bits.U1TXIF = 0;
    IFS0bits.U1RXIF = 0;
    IFS0bits.U1EIF  = 0;

    IPC6CLR = 0x0000001F;

    U1BRG    = BAUD;

    U1MODE = 0x00000000;

    IEC0bits.U1TXIE = 0b1;
    IEC0bits.U1RXIE = 0b1;
    IEC0bits.U1EIE  = 0b1;

    IPC6bits.U1IP   = 0b110;
    IPC6bits.U1IS   = 0b10;
    
    U1STAbits.UTXISEL = 0b01; //00;01;10    //transmit interrupt mode
    U1STAbits.URXISEL = 0b11; //00;01;10;11 //receive interrupt mode

    U1MODEbits.ON   = 0b1;

    U1STAbits.UTXEN = 0b1;
    U1STAbits.URXEN = 0b1;

    IFS0bits.U1TXIF = 0; //clear Interrupt-flag
}

Interrupt-Handler for UART:

void __ISR(_UART_1_VECTOR,IPL7) Uart1Handler(void){
    if(IFS0bits.U1TXIF & 0b1)
    {
        //Do something maybe
	IFS0bits.U1TXIF = 0; //clear IntFlag!!
    }
    if(IFS0bits.U1RXIF & 0b1)
    {
	IFS0bits.U1RXIF = 0;
        //Do RX stuff here
    }
    if(IFS0bits.U1EIF & 0b1)
    {
	IFS0bits.U1EIF = 0;
    }
}

regards Dennis


KeithV

Tue, 14 May 2013 14:28:31 +0000

remember UART1 is connected to the FTDI chip. If you want to talk direct Serial, it might be safer not to use UART1. You can use UART1, you just have to understand that the FTDI chip is part of the mix.


cerebot_fontys

Wed, 22 May 2013 20:58:43 +0000

Hi i have tried the same with UART2 and got the same problem.

I even tried it with the older MX7-version, without the FTDI on UART1, and I still can't clear the interrupt-flag.

regards


devrirobotik

Sun, 21 Dec 2014 09:08:52 +0000

HEY.. Can you clear Interrupt flags now??? Please help?? I couldn't clear that da.. flag too... :(((((( Please help!