I2C : interruption problem when passing from psoc4 to psoc5

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

cross mob
ThDe_4683671
Level 1
Level 1
10 sign-ins 5 replies posted 5 sign-ins

Hello,

I have a project where I have to use a sensor (the VL53L0X) for wich a code is already available for the psoc4. I did the translation to psoc 5 but I had a problem with the functions who read and write informations from the master.

tempsnip.png

(this is the originat code written for psoc 4)

The problem is that each time the program goes into these functions, the CPU is halted by an interruption.

I found a solution which consists in disabling the global interruptions around these functions.

pastedImage_1.png

My question is thus : Why have I to do it, where does the probem come from ?

Thanks.

0 Likes
1 Solution
Hari
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hi ThDe_4683671

In that case, it looks like the master (PSoC) is sending out data. Please confirm the data rate of the slave and make sure that master is also configured to the same speed.

You can also verify the integrity of the data and confirm if this is the format in which slave expects (assuming you have the waveform still).

Thanks,

Hari

View solution in original post

5 Replies
Hari
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hi thde_4683671

PSoC 5LP I2C works based on interrupts. Hence, it is not suggested to disable and enable the interrupts before the function call. Please make sure that the Interrupts are enabled globally before the first function is called. that is, make sure that CyGlobalIntEnable is executed before the first I2C function is called.

Also, check the waveform on the I2C bus to make sure that some data is being transferred. you should see atleast the SCL clock pulses.

Can you also remove the current modification of interrupts and run the program in debug mode to check where the CPU is getting stuck?

Please share the project so that we can check the code at our end as well that would help with easier debug.

Thanks,

Hari

0 Likes

Sadly, due to the covid-19, I don't have any access to the device I'm working on ...

Thus I cannot have a debug vision of the execution. I remember the clock was working but the sda tried to send three times the same init information with always NACK answer from the slave. After that the clock was stopped and the program was stuck in a function in the cyhalt.c file...

0 Likes
ThDe_4683671
Level 1
Level 1
10 sign-ins 5 replies posted 5 sign-ins

Here is the source of the code I use (without disabling the interrupt)

https://www.hackster.io/vlad-radoiu/measuring-distance-with-vl53l0x-tof-sensor-1080f1

0 Likes
Hari
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hi ThDe_4683671

In that case, it looks like the master (PSoC) is sending out data. Please confirm the data rate of the slave and make sure that master is also configured to the same speed.

You can also verify the integrity of the data and confirm if this is the format in which slave expects (assuming you have the waveform still).

Thanks,

Hari

AH_96 a écrit:

Hi ThDe_4683671

In that case, it looks like the master (PSoC) is sending out data. Please confirm the data rate of the slave and make sure that master is also configured to the same speed.

You can also verify the integrity of the data and confirm if this is the format in which slave expects (assuming you have the waveform still).

Thanks,

Hari

Thank you very much, the problem shoukd come from a difference between the frequencies of the slave and the master. Indeed, the frequency of master was too high.

0 Likes