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.

C6720 - Writing only 8 bits to the Asynchronous Bus

I have a custom C6720 board with a 16 bit asynchronous bus.  I have a block within this external memory decoded for peripherals.  I am using CCS and writing the code in C++.  My issue is when I try to write this peripheral area, I am getting a word type writes (multiple strobes of the EM_CS2 line) and the additional strobes are causing data corruption (as the 8 bits are being outputted correctly on the first strobe, and the 8 bits change when making the additional strobe(s)).

In my C code, I have a header file setting up pointers to these peripheral locations ie:

unsigned int* const dspgpio= (unsigned int*)0x900C0020;

And I have in my main a function to select the memory block (using GPIO pins for and write the information:

void wexdat(unsigned int* const Address, char wdata)
{
    if (Address>=(unsigned int* const)0x900C0000 && Address<(unsigned int* const)0x900E0000)
        {//Write to On Board Peripheals
        *MC0_PDCLR=0xFFFFFFFF;
        *MC0_PDSET=0x00000C00;
        }
    else
        {//Write to Off Board Peripheals
        *MC0_PDCLR=0xFFFFFFFF;
        *MC0_PDSET=0x00000C10;
        }

    *Address=wdata;
}

I have tried passing wdata as a short as well with no change in the result. 

I have also done experiments with the ACR1 register, if setup for 8 bit bus, 4 strobes occur; if setup for 16 bit bus, 2 strobes occur; however, if setup for 32 bit which is an illegal condition for this processor, only 1 strobe occurs.

Does anyone know a legal way through software to make a byte write.  It does say byte writes are possible through the manual.  Or can I run in this illegal state.  I do not have SDRAM so the refreshing mode is not an issue also, if I need to write words to my memories, I can always switch the ACR1 register back to a 16 bit bus.

Thank you in advance for your help.  Regards

  • The size of wdata is not as important as the data type of the pointer itself (in your example Address is the pointer). Because Address is an integer pointer, it is attempting to write 32-bits through the EMIF. When you have a 16- or 8-bit EMIF bus width the EMIF is smart enough to chop up the 32-bit value into 4 or 2 different writes, respectively.

    To fix this you could do something like the following:

    dan kantorski said:
    void wexdat(unsigned short* const Address, char wdata)
    {
        if (Address>=(unsigned int* const)0x900C0000 && Address<(unsigned int* const)0x900E0000)
            {//Write to On Board Peripheals
            *MC0_PDCLR=0xFFFFFFFF;
            *MC0_PDSET=0x00000C00;
            }
        else
            {//Write to Off Board Peripheals
            *MC0_PDCLR=0xFFFFFFFF;
            *MC0_PDSET=0x00000C10;
            }

        *Address=wdata;
    }
    Note that even though the Address pointer is of type short it is still storing a 32-bit address - the data type simply states that it points to a 16-bit value at that address. Similarly, if you pass a pointer of type char then Address would instead point to an 8-bit value.

  • I replaced all the "unsigned int" declarations to "char" throughout my constants and function and that did the trick.

    Thank you.