cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 4 MCU

New Contributor

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
Reply
1 Solution
Moderator
Moderator

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
Moderator
Moderator

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
Reply
New Contributor

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
Reply
New Contributor

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
Reply
Moderator
Moderator

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

New Contributor

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
Reply