AnsweredAssumed Answered

Sport problem when simulating Uart TX

Question asked by Fagner on Sep 29, 2009
Latest reply on Oct 1, 2009 by Fagner

Hi,

I need more than one UART in my project (with BF533), so i have to use sport as secundary uart. The communication is between ezkit and a PC. I am using 9600bps 8N1. By now i am using sport register mode (no dma).The reception is working fine, but when i have to transmit some chars the last one is never transmitted right (i get a 0xFF instead). The code below should transmit char 2 and 3. But only char 2 is received by the PC. If i program to transmit three chars, PC only gets two and so on..

 

regards,

Fagner

 

 

My code:

 

main(){

...

    *pSPORT1_TCR1 = 0x0000;     // be sure rx port is disabled

    *pSPORT1_TCR2 = 0x0000;     // be sure rx port is disabled

       
    // TX config
    *pSPORT1_TCLKDIV = 0x182B;        //118.800.000/2*9600
    *pSPORT1_TFSDIV = 10;            //
    *pSPORT1_TCR2 = 9;
    *pSPORT1_TCR1 = ITCLK | TLSBIT | LATFS| TFSR| LTFS;
    ssync();

 

     *pSPORT1_TX16 = (unsigned short)0x0264;     //start bit + ch'2' + stop bit   
     ssync();
    *pSPORT1_TX16 = (unsigned short)0x0266;     ////start bit + ch'3' + stop bit   
    ssync();

    *pSPORT1_TCR1 |= TSPEN;        //tx enable 

    ssync();

...

}

 

void Init_Interrupts(void)
{
   
    // configure interrupt   
    *pSIC_IAR0 = *pSIC_IAR0 & 0xffffffff | 0x00000000;    // map SPORT0 Error Interrupt -> IVG7
    *pSIC_IAR1 = *pSIC_IAR1 & 0xffffffff | 0x33322221;    //
                                   
    register_handler(ik_ivg7, SPORT1_ERROR_ISR);
    register_handler(ik_ivg9, SPORT1_ISR);      
   
    *pSIC_IMASK=SPORT1_ERR_IRQ | DMA4_IRQ;
    ssync();  

 

}//end Init_Interrupts

 

EX_INTERRUPT_HANDLER(SPORT1_ISR)    // <--|declaration in  exception.h -->
{
    int i;
    unsigned short statreg=0;
   
    *pDMA4_IRQ_STATUS = 0x1;
    ssync();

 

    while ((*pSPORT1_STAT & 0x0040) == 0)        // While HOLD not empty....
    {asm("nop;");};

    *pSPORT1_TCR1 &= ~0x0001;                    // Disable Transmit INT     

 

}//end DMA0_PPI_ISR

 

EX_INTERRUPT_HANDLER(SPORT1_ERROR_ISR)    // <--|declaration in  exception.h -->
{
    unsigned short statreg;   
    statreg = *pSPORT1_STAT;   
   
    if (statreg & TUVF){ //W1C
        *pSPORT1_STAT = statreg | TUVF;
        ssync();
        txUnderflowStatus++;
        ssync();
    }
    if (statreg & TOVF){ //W1C
        *pSPORT1_STAT = statreg | TOVF;
        ssync();
        txOverflowStatus++;
        ssync();
    }
   
    if (statreg & TXHRE){ //
        txHoldRegEmpty++;       
        ssync();
        *pSPORT1_TCR1 &= TSPDISABLE;        //tx disable
        ssync();
    }
    if (statreg & TXF){ //
        txFifoFull++;
        ssync();   
    }

 

}//end SPORT1_ERROR_ISR

Outcomes