This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

mibSPI multi-Buffer RAM parity detection doesn't work well

Other Parts Discussed in Thread: HALCOGEN

I'm using HALCoGen 2.09.000 .
In the generated code spiInit(), i use this function to enable parity check and parity bits memroy mapped:
    SPI_EnableRAMParityCheck(spiREG1);
    /** - initalise buffer ram */
    {   int i = 0;

        if (10 > 0)
        {
            while (i < 10-1)
            {
                spiRAM1->tx[i++].control = (4 << 13)  /* buffer mode */
                                         | (1 << 12)  /* hold chip select */
                                         | (1 << 11)  /* lock transmission */
                                         | (0 << 8)  /* data format */
                                         | CS_0;  /* chip select */
            }
            spiRAM1->tx[i++].control = (4 << 13)  /* buffer mode */
                                     | (0 << 12) /* chip select hold */
                                     | (1 << 10)  /* enable WDELAY */
                                     | (0 << 8)  /* data format */
                                     | CS_0;  /* chip select */
        }
        ...
    }

void SPI_EnableRAMParityCheck(spiBASE_t *spi)
{
 spi->PTESTEN = 1; /* parity bits are memory mapped */
 spi->EDEN = 0xA;  /* parity error detection is enabled */
}

but while debugging, i didn't see the parity bits updated.
for example, spi1 tx memory 0xFF0E0000 value is 0x980E0000, the parity bit memeory 0xFF0E0000+0x400 value
is 0x01010101(this is the init parity bit value, i use the default odd parity detection in reg.0xFFFFFFDC).

Even i use spiSetData() to set the tx buffer, the parity bits still not updated, so, when i start spi communication
 use spiTransfer(), the parity error detected. what's the problem? how to solve it? Much thanks.

  • Fumin Li said:

    I'm using HALCoGen 2.09.000 .
    In the generated code spiInit(), i use this function to enable parity check and parity bits memroy mapped:
        SPI_EnableRAMParityCheck(spiREG1);
        /** - initalise buffer ram */
        {   int i = 0;

            if (10 > 0)
            {
                while (i < 10-1)
                {
                    spiRAM1->tx[i++].control = (4 << 13)  /* buffer mode */
                                             | (1 << 12)  /* hold chip select */
                                             | (1 << 11)  /* lock transmission */
                                             | (0 << 8)  /* data format */
                                             | CS_0;  /* chip select */
                }
                spiRAM1->tx[i++].control = (4 << 13)  /* buffer mode */
                                         | (0 << 12) /* chip select hold */
                                         | (1 << 10)  /* enable WDELAY */
                                         | (0 << 8)  /* data format */
                                         | CS_0;  /* chip select */
            }
            ...
        }

    void SPI_EnableRAMParityCheck(spiBASE_t *spi)
    {
    // spi->PTESTEN = 1; /* parity bits are memory mapped */

    HW: once you did this, parity bit is no longer automatically updated. Comment this line and enable it only when you want to read or modify(test) the parity bit.

    Otherwise, you will get parity error.

    If you want to introduce a parity error, you can:

    1. spi->PTESTEN = 1;

    2. Modify the parity bit

    3.spi->PTESTEN = 0;

    4. Read the memory (not the parity memory) either by CPU or SPI spi->EDEN = 0xA;  /* parity error detection is enabled */
    }

     

    but while debugging, i didn't see the parity bits updated.
    for example, spi1 tx memory 0xFF0E0000 value is 0x980E0000, the parity bit memeory 0xFF0E0000+0x400 value
    is 0x01010101(this is the init parity bit value, i use the default odd parity detection in reg.0xFFFFFFDC).

    Even i use spiSetData() to set the tx buffer, the parity bits still not updated, so, when i start spi communication
     use spiTransfer(), the parity error detected. what's the problem? how to solve it? Much thanks.