STSCBE
Member level 2
Hi all,
Here i'm facing the problem with dsPIC33f UART Transmitter interrupt..
Before that im using via polling. then i configure Transmitter as interrupt. when im, transmitting array, only 5 character is sent. remaining characters are not sent. I dont know where is the problem and im not written full code here.
Here i'm facing the problem with dsPIC33f UART Transmitter interrupt..
Before that im using via polling. then i configure Transmitter as interrupt. when im, transmitting array, only 5 character is sent. remaining characters are not sent. I dont know where is the problem and im not written full code here.
Code:
void UART_init(void)
{
// UART1 initialization
U1MODEbits.STSEL = 0; // 1-Stop bit
U1MODEbits.PDSEL = 0; // No Parity, 8-Data bits
U1MODEbits.ABAUD = 0; // Auto-Baud disabled
U1MODEbits.BRGH = 0; // Standard-Speed mode
U1BRG = BRG_RS232; // Baud Rate setting
U1STAbits.UTXISEL0 = 0; // Interrupt after one TX character is transmitted
U1STAbits.UTXISEL1 = 0; //Interrupt when a character is transferred to the Transmit Shift Register
U1STAbits.URXISEL = 0; // Interrupt after one RX character is received;
IEC0bits.U1RXIE = 1; // Enable UART 1 RX interrupt
IPC2bits.U1RXIP = UART1_INT_PRIORITY; //UART1 interrupt priority
U1MODEbits.UARTEN = 1; // Enable UART
U1STAbits.UTXEN = 1; // Enable 1 UART TX
// UART2 initialization
U2MODEbits.STSEL = 0; // 1-Stop bit
U2MODEbits.PDSEL = 0; // No Parity, 8-Data bits
U2MODEbits.ABAUD = 0; // Auto-Baud disabled
U2MODEbits.BRGH = 0; // Standard-Speed mode
U2BRG = BRG_MOD; // Baud Rate setting
U2STAbits.UTXISEL0 = 0; // Interrupt after one TX character is transmitted
U2STAbits.UTXISEL1 = 0; //Interrupt when a character is transferred to the Transmit Shift Register
U2STAbits.URXISEL = 0; // Interrupt after one RX character is received;
IEC1bits.U2RXIE = 1; // Enable UART 2 RX interrupt
IPC7bits.U2RXIP = UART2_INT_PRIORITY; //UART2 interrupt priority
U2STAbits.UTXISEL0 = 0; // Interrupt after one TX character is transmitted
U2STAbits.UTXISEL1 = 0;
IEC1bits.U2TXIE = 1; // Enable UART TX interrupt
U2MODEbits.UARTEN = 1; // Enable UART
U2STAbits.UTXEN = 1; // Enable 2 UART TX
}
unsigned char ay[] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
unsigned int z=0;
unsigned int ab=0;
void SendArrElement();
int main(void)
{
UART_init();
SendArrElement();
for( ; ; )
{
RCONbits.SWDTEN = 0; //to clear watch dog timer
}
return 0;
}
void SendArrElement()
{
for(z=0; z<=25; z++)
{
U2TXREG = ay[z];
}
}
void __attribute__((__interrupt__, __no_auto_psv__)) _U2TXInterrupt(void)
{
IFS1bits.U2TXIF = 0; // Clear TX Interrupt flag
}