16 bit

Forum for problems or queries regarding Flowcode Comms Components. Eg LIN, I2C, SPI, RS232, CAN, IrDA etc

Moderators: Benj, Mods

Post Reply
stevel
Posts: 19
Joined: Sat Sep 05, 2009 2:18 pm
Contact:

16 bit

Post by stevel »

Can some one help me out please i need to send 16 bits to the spi not sure how to do this. Also i am new to flowcode file attached can some one alter this for me so it sends 16 bit please
Attachments
255spi.fcf
(6.5 KiB) Downloaded 422 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: 16 bit

Post by Benj »

Hello

Ok firstly you need to create an INT variable to hold your 16-bit number. Then you can create two byte variables to hold the upper and lower 8-bits.

Calculation Icon:
Int = 16-bit number
byte_low = Int & 0xff
byte_high = ( Int >> 8 ) & 0xff

If you need to recombine the two bytes into a 16-bit number (eg when reading data back) then you do it like this.

Calculation Icon:
Int = byte_low
Int = Int + ( byte_high << 8 )

stevel
Posts: 19
Joined: Sat Sep 05, 2009 2:18 pm
Contact:

Re: 16 bit

Post by stevel »

hi there thanks for the reply but i have not got a clue of what to do i dont know how to create a int variable then the next steps of doing byte variables to hold my 16 bit number. like i said i am new to flow code and i find doing things in the programme very hard so please can u send me example of how to do this as i am totaly confused

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: 16 bit

Post by Benj »

Hello

First a link for any Flowcode beginner.
http://www.matrixmultimedia.com/lc_microcontroller.php

Secondly variables are created in the variable manager located in the edit menu.

Thirdly here is an example however if you are new to Flowcode then I would go through the course and the tutorials to get up to speed.
Attachments
Flowcode1.fcf
(4 KiB) Downloaded 462 times

Post Reply