CMSIS: Analyzing run-time issues with a CMSIS-Driver
Information in this knowledgebase article applies to:
My application is using a CMSIS-Driver for I2C communication. But what happens is that my program program apparently hangs. I traced the execution and found this sequence of function calls:
GUI_Init => GUI_X_Init => GUI_TOUCH_Initialize => Touch_Initialize => Touch_Write
Inside Touch_Write there is this statement which is a call to a CMSIS-Driver function:
That is the statement where the program hangs and it looks like the I2C controller is always busy and the while loops continuously. How can I analyze the source of the problem?
You should first verify that the CMSIS-Driver (in your case the I2C interface) is correctly initialized. Your source code contains perhaps statements like this:
ptrI2C->Initialize (NULL); ptrI2C->PowerControl (ARM_POWER_FULL); ptrI2C->Control (ARM_I2C_BUS_SPEED, ARM_I2C_BUS_SPEED_FAST); ptrI2C->Control (ARM_I2C_BUS_CLEAR, 0);
Most CMSIS-Driver functions return a status information, but apparently these status information is not checked in your application. You should therefore implement a proper error handling for that and check if the driver is correctly initialized. Your code modification may look like this and provide a function for error handling.
status = ptrI2C->Initialize (NULL); if (status != 0) error_handling (); status = ptrI2C->PowerControl(ARM_POWER_FULL); if (status != 0) error_handling (); status = ptrI2C->Control (ARM_I2C_BUS_SPEED, ARM_I2C_BUS_SPEED_FAST); if (status != 0) error_handling (); status = ptrI2C->Control (ARM_I2C_BUS_CLEAR, 0); if (status != 0) error_handling ();
In case that the driver is correctly initialize, you should verify that the I2C interface transmits data. It might be that the pin assignments or the setup of the peripheral is incorrect.
Last Reviewed: Wednesday, January 25, 2017
of your data.