16 bit
16 bit
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 474 times
- 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
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 )
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 )
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: 16 bit
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
- 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
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.
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 519 times
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel