Problems with the Relax Kit-Board SPI-communicaton

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Not applicable
Hi everyone,
my name is Christian and I'm a student of Electrical Engineering in Germany. After having realized several μC projects including TI'sMSP430, I would like to work with Infineon Controllers in my next project. Different measured values should be visualized on a display. Unfortunately, the communication via the SPI-interface doesn't work correctly yet. The display used is a DOGL from the company “Electronic Assembly”. The controller is an Infineon Relax Kit-Board combined with an XMC4500-F100F1024 controller. I am using a Dave 3 Toolchain for the software development. The communication between the display and the controller works via SPI (Half Duplex).

I have two (comprehension) problems:

1. To make it possible for the display to distinguish Command and Data, the Pin A0 has to be switched to "LOW" for Command and to "HIGH" for Data. Thus, first A0 should be switched to “HIGH” to send the data and then the data should be sent via SPI (figure 1). In my opinion, it should look
like that. Of course, I have to wait for the Transmit Buffer to be empty and then A0 has to be switched to “LOW” again. Unfortunately, I can't find the corresponding register which is only deleted when the transmit has beenfinished. I've looked through the data sheets and the user's guide but
couldn't find anything. Maybe you can give an example.

2. As you can see in the source code, 16 hex values should be transferred one after the other. This shouldbe repeated in the while-forever-loop. My expectation is that the values are sent viathe SPI-periphery successively and in the order given by the array. Unfortunately, only a small amount of data is sent and this doesn't happen in the right order (figure 2). I think I made a mistake with the dave-settings of the SPI-interface.

I hope you are able to help me.

Regards,
Christian



/*
* Main.c
*
* Created on: 29.05.2013
* Author: Christian
*/





#include //Declarations from DAVE3 Code Generation (includes SFR declaration)


int main(void)
{
// status_t status; // Declaration of return variable for DAVE3 APIs (toggle comment if required)

// Init DOGL
const char init[] = {0x40, //Display start line 0
0xA1, //ADC reverse
0xC0, //Normal COM0...COM63
0xA6, //Display normal
0xA2, //Set Bias 1/9 (Duty 1/65)
0x2F, //Booster, Regulator and Follower On
0xF8, //Set internal Booster to 4x
0x00,
0x27, //Contrast set
0x81,
0x10,
0xAC, //No indicator
0x00,
0xAF, //Display on
0xb0, //Page 0 einstellen
0x10, //High-Nible der Spaltenadresse
0x00 //Low-Nible der Spaltenadresse
};

int i = 0;
uint16_t SendData;


DAVE_Init(); // Initialization of DAVE Apps




while(1)
{


IO004_SetPin(IO004_Handle0);

while(i<16){

SendData = init;
// write data to tbuf depending on transmit mode
SPI001_WriteData(&SPI001_Handle0,&SendData,SPI001_STANDARD );
while((SPI001_GetFlagStatus(&SPI001_Handle0, SPI001_TRANS_BUFFER_IND_FLAG ))!=SPI001_SET){}
i++;
}

IO004_ResetPin(IO004_Handle0);
i=0;



}
return 0;
}
0 Likes
4 Replies
Not applicable
hi

From your source code, when you send out the data, the transmit mode is SPI001_STANDARD but I think that's for full duplex communication.
For half duplex communication, you need to use SPI001_STANDARD_HPC_OUTPUTMODE.

I don't quite understand on your problem (1). Perhaps you can explain what register you are looking for?


rgds,
Rou
0 Likes
Not applicable
Hi Rou,

you are right! thx

using the msp430 for SPI-communication it's works fine with the following code:

UCB0TXBUF = value; // Send data
while (!(IFG2&UCB0RXIFG)); // Wait for TX to finish
IFG2 &= ˜UCB0RXIFG; // Clear flag
UCB0TXBUF = value; // Send data
while (!(IFG2&UCB0RXIFG)); // Wait for TX to finish

with this code the µC wati until the data was send and the Transmit-flag ist set. I'm search for such an equal flag to know when the transmit is done. I think it must be equal to:

while(i<16){

SendData = init;
// write data to tbuf depending on transmit mode
SPI001_WriteData(&SPI001_Handle0,&SendData,SPI001_STANDARD_HPC_OUTPUTMODE );
while((SPI001_GetFlagStatus(&SPI001_Handle0, SPI001_FIFO_STD_TRANSMIT_BUF_FLAG))!=SPI001_SET)
SPI001_ClearFlag(&SPI001_Handle0,SPI001_FIFO_STD_TRANSMIT_BUF_FLAG);

i++;
}

But it doesn't work!

I want generate an output like in this picture. Before the Transmit A0 it's set "HIGH". CS is set automatically. If the tramsmit was done the code continue and set A0 to "LOW".

Regards,

Christian
0 Likes
Not applicable
hi Christian,

If I get your question correctly, you need a flag to indicated that your data has finished transmitted. Am I correct?
If that's the case, then I think you have poll for the wrong flag.
Instead of polling SPI001_FIFO_STD_TRANSMIT_BUF_FLAG, I think you should poll for SPI001_TRANS_SHIFT_IND_FLAG.
The SPI001_FIFO_STD_TRANSMIT_BUF_FLAG indicate the FIFO trigger level, which is not what you want.
For data to finished transmitted, it is indicated in SPI001_TRANS_SHIFT_IND_FLAG.


rgds,
Rou
0 Likes
Not applicable
Hi Rou,


sry for my late answer. It's works, thanks for help:-)

Regards,


Christian
0 Likes