+ Post New Thread
Results 1 to 3 of 3
  1. #1
    Member level 2
    Points: 494, Level: 4

    Join Date
    Jul 2016
    Posts
    43
    Helped
    0 / 0
    Points
    494
    Level
    4

    problem with dspic33f UART transmitting interrupt

    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
    }

    •   Alt20th September 2017, 04:38

      advertising

        
       

  2. #2
    Super Moderator
    Points: 237,346, Level: 100
    Awards:
    1st Helpful Member

    Join Date
    Jan 2008
    Location
    Bochum, Germany
    Posts
    41,069
    Helped
    12542 / 12542
    Points
    237,346
    Level
    100

    Re: problem with dspic33f UART transmitting interrupt

    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.


    1 members found this post helpful.

    •   Alt20th September 2017, 05:44

      advertising

        
       

  3. #3
    Member level 2
    Points: 494, Level: 4

    Join Date
    Jul 2016
    Posts
    43
    Helped
    0 / 0
    Points
    494
    Level
    4

    Re: problem with dspic33f UART transmitting interrupt

    Quote Originally Posted by FvM View Post
    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?



--[[ ]]--