Page 1 of 1

16 bit

Posted: Tue Oct 06, 2009 12:44 pm
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

Re: 16 bit

Posted: Tue Oct 06, 2009 1:52 pm
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 )

Re: 16 bit

Posted: Tue Oct 06, 2009 2:38 pm
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

Re: 16 bit

Posted: Tue Oct 06, 2009 3:40 pm
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.