I2C example doubt

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

cross mob
Anonymous
Not applicable

Hello

   

I'm seeing the example of delsig_I2CM01 in psoc creator, but i don't understand this lines:

   

        sample_segment[0] = sample_full >> 8u & 0x00FFu;
        sample_segment[1] = sample_full & 0x00FFu;

   

someone could explain to me these lines

   

 

   

Thanks for your help

0 Likes
3 Replies
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

This converts a 16-bit-integer (sample_full) into an array (sample_segment) containing two bytes. While doing so, it changes endianess: the int16 is stored differently on PSoC5 (lowest byte first) and PSoC3 (highest byte first), and in the array its always highest byte first.

0 Likes
Anonymous
Not applicable

Well, what I understando you is next:

   

-ADC converts to a 16-bits samplefull

   

-then converts sample full into a matrix with two bytes

   

and this is to send one byte per time

   

it's ok?

   

thanks for yout help

0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

I did not search where that come comes from, but yes I guess it does what you think.

0 Likes