Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

problem with dspic33f UART transmitting interrupt

Status
Not open for further replies.

STSCBE

Member level 2
Joined
Jul 9, 2016
Messages
43
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Activity points
360
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.
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
}
 

Completely flawed. Either use polling without interrupts, then you need to check for free UART fifo space before writing to TXREG. Or transfer data to TXREG in interrupt.
 
  • Like
Reactions: STSCBE

    STSCBE

    Points: 2
    Helpful Answer Positive Rating
Completely flawed. Either use polling without interrupts, then you need to check for free UART fifo space before writing to TXREG. Or transfer data to TXREG in interrupt.

i found there is delay problem. but i dont know how to send an array using interrupt. How to trigger manually to transmit array, once my array is full?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top