OK, I still can not get this dam thing to work. I don't understand why the dsPICs are so much more difficult than all the others. I got a PIC32 on the board to work just fine in minutes, but this dsPIC just simply wont.
All I'm trying to do is get the Rx interrupt to work but its just not happening. Even when I run the thing in loop-back mode and spitting on stuff on the Tx pin, nothing happens. I'm stumped. Can anyone see what I'm doing wrong?
/*
**UART Example for dsPIC30F2011
*/
#include <p30f2011.h>
#include <uart.h>
//setup the UART
void initUART(void)
{
U1BRG = 51; //baud rate of 9600, 8MHz XT, No PLL
U1MODE = 0x8400; // Enable, 8data, no parity, 1 stop, (8-N-1), enable alternate UART pins
U1STA = 0x8400; // Enable Tx and Tx interrupt
while(U1STAbits.UTXBF==1); //empty the Tx buffer
U1STAbits.OERR = 0; //clear any errors so data can be received
IFS0bits.U1RXIF=0; /* clear UART1 receiver interrupt flag */
IFS0bits.U1TXIF=0; /* clear UART1 transmitter interrupt flag */
IEC0bits.U1RXIE=1; /* enable UART1 receiver ISR */
//enable Rx intterupt, disable Tx interrupt
//ConfigIntUART1(UART_RX_INT_EN & UART_RX_INT_PR6 & UART_TX_INT_DIS & UART_TX_INT_PR2);
}
//main loop
int main(void)
{
TRISD = 0; //set the direction of Port D (output)
initUART(); //initialize the UART
PORTD = 0x00; //set all pins are Port D low
while(1); //wait for something to happen
}
//Rx ISR
void _ISR_PSV_U1RXInterrupt(void)
{
putcUART1(U1RXREG); //echo back the value
PORTD = 0x01; //turn on a LED
IFS0bits.U1RXIF = 0; //clear UART1 RX interrupt flag
}