AnsweredAssumed Answered

sport overflow error but status is partially full

Question asked by verysmallbits on Apr 20, 2017
Latest reply on Apr 26, 2017 by rf247

I'm using sport0, primary only, as a receiver with external clocks.


right now i'm just making sure everything is robust using just polling before i switch to DMA mode, and, of course, it's not.


i simply loop over the number of samples i want, checking to see if the RX buffer has become full.  when it's full, i read the primary RX data register and continue on.


so on a fairly regular basis i get a situation where the routine errors out, because


SPORT_ERR_A = 0x10


CTL_A = 0xa00919f1


which indicates the buffer is partially full.


how is this possible ? if there's a buffer overflow, then the buffer must be full or it would not have overflowed.


the other question is, what is the proper method to run in polling mode ?


should i actually be reading the data register when i see that ctl_a indicates the buffer is partially full, or wait until it indicates that it is full ?


Thank you,


actual code:

    // enable the SPORT A
    ctla = *pREG_SPORT_CTL_A;
    ctla |= ENUM_SPORT_CTL_EN;
    *pREG_SPORT_CTL_A = ctla;
    err = *pREG_SPORT_ERR_A;


    i = 0;
    while (i < nsamples*2 && err == 0)
        tries = 0;
        ctla = *pREG_SPORT_CTL_A;
        pstatus = ctla & BITM_SPORT_CTL_DXSPRI;
        err = *pREG_SPORT_ERR_A;
        while (pstatus != ENUM_SPORT_CTL_PRM_FULL && err == 0) {
            ctla = *pREG_SPORT_CTL_A;
            pstatus = ctla & BITM_SPORT_CTL_DXSPRI;
            err = *pREG_SPORT_ERR_A;
            tries = tries + 1;
        if (err == 0) {
            data = *pREG_SPORT_RXPRI_A;
            if ((i & 0x1) == 0x0) {
                lbuffer[i>>1] = data;
            } else {
                rbuffer[i>>1] = data;
            i = i + 1;