xmc 4500 I2C no output and all USIC register appeear as 0xFFFFFF

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

cross mob
Not applicable
Hi all!
I've having an issue with my XMC4500 relex kit and usic channel. Here's my code:

volatile uint8_t tx_completion_0 = 0;

/* Transmit callback handling */
void tx_callback_0(void)
{
tx_completion_0 = 1;
}

int main(void)
{
DAVE_STATUS_t status;
uint8_t tr1[7] = { OLED_CONTROL_BYTE_CMD_STREAM, OLED_CMD_SET_COLUMN_RANGE, 0x00, 0x7F, OLED_CMD_SET_PAGE_RANGE,0x00, 0x07 };
status = DAVE_Init(); /* Initialization of DAVE APPs */
XMC_DEBUG("here at least?...")
if(status == DAVE_STATUS_FAILURE)
{
/* Placeholder for error handler code. The while loop below can be replaced with an user error handler. */
XMC_DEBUG("DAVE APPs initialization failed\n");

while(1U)
{

}
}

/* Placeholder for user application code. The while loop below can be replaced with user application code. */

while(1U)
{

I2C_MASTER_Transmit(&I2C_MASTER_0, true, OLED_I2C_ADDRESS, tr1, 7, true );
while(!tx_completion_0);
tx_completion_0 = 0;

for(uint16_t i=0;i<1024;i++){

I2C_MASTER_SendStart(&I2C_MASTER_0, OLED_I2C_ADDRESS, XMC_I2C_CH_CMD_WRITE);
I2C_MASTER_TransmitByte(&I2C_MASTER_0, OLED_CONTROL_BYTE_DATA_STREAM);
while(!tx_completion_0);
tx_completion_0 = 0;
for (uint8_t x=0; x<16; x++) {
I2C_MASTER_TransmitByte(&I2C_MASTER_0, 0x81);
while(!tx_completion_0);
tx_completion_0 = 0;
i++;
}
I2C_MASTER_SendStop(&I2C_MASTER_0);
}
}
}

As you can see it's almost a copy from the I2C example, but still doesn't give me any output ( I configured the end of transmit callback to be function tx_callback_0 and the pins to be SCl:0.8 and SDA:1.5)
and in the debugger when I lock at USIC0_C0 address I find all ones
2308.attach

Thanks in advance!
0 Likes
3 Replies
DRubeša
Employee
Employee
First solution authored First like received
Hi,

when you see that all the registers are in "all one" state, you can always be sure that module is not enabled (used peripheral is not powered on). In your case this should be done by the function:

Dave_Init() -> I2C_MASTER_Init(&I2C_MASTER_0) -> I2C_MASTER_0_init() -> XMC_I2C_CH_Init(XMC_I2C0_CH0, &I2C_MASTER_0_channel_config) -> XMC_USIC_CH_Enable(channel)

And why these functions are not executed in your case in the order I just mentioned 🙂 ? Can you please verify that you generated DAVE APP code?

So first:
2309.attach

Then:
2310.attach

Try then to debug the code...I guess at least the registers shouldn´t be all one like now. Also, one additional advice... Due to the fact that you selected pins that belong to the module USIC0 channel 0, DAVE should automatically configure usage of that module and channel. However, just to be sure that it´s really using proper channel and that you should be looking at memory monitor for USIC0C0, you can select "Report":
2311.attach

And then you should see something exactly as it is shown on the figure below:
2312.attach

Try things above that I´ve mentioned and let me know have we at least solved something...I cannot guarantee that the code will work, that I will leave for you to check 😛

Best regards,
Deni
0 Likes
Not applicable
Hi! Thanks for the response! 😄
I looked into what you've said and I found that inside I2C_MASTER_Init();

2C_MASTER_STATUS_t I2C_MASTER_Init(const I2C_MASTER_t *const handle)
{
I2C_MASTER_STATUS_t status;

if (handle != NULL)
{
/*Initialize the multiplexers required for I2C_MASTER configuration*/
handle->config->fptr_i2c_config();

status = I2C_MASTER_STATUS_SUCCESS;
}
else
{
status = I2C_MASTER_STATUS_FAILURE;
}
return (status);
}

As you can see there is no "I2C_MASTER_0_init()" so I added it myself (between handle->config->fptr_i2c_config(); and status = I2C_MASTER_STATUS_SUCCESS; ) , from that point ahead every function is called in the order you specified, and teh report manager shows everything as you mentioned:
2317.attach

but unfortunately the problem still persist, and still get the channel disabled.

Best regards and thanks!
Luis
0 Likes
DRubeša
Employee
Employee
First solution authored First like received
Hi Luis,

you don´t need to add anything 🙂

That "handle->config->fptr_i2c_config();" will call "I2C_MASTER_0_init()". That´s like a callback and when the code executes line "handle->config->fptr_i2c_config();", code execution will jump to "I2C_MASTER_0_init()". Just try to debug using step by step debugging...you will notice how code passes exactly through all the functions that I mentioned in the first in that order. Try to debug and see does the content of the USIC0C0 registers change after execution of the "XMC_USIC_CH_Enable(channel)" function.

Best regards,
Deni
0 Likes