PDA

View Full Version : missing high bits of word val



archendekta
- 25th December 2009, 05:47
what i was hoping to accomplish was to put the counter val into the 17th element of the array of type word.

but, it is only putting an 8-bit value and not a 16-bit value. i'm missing the high bits.

i need a small push here to help me get the 16-bit val into an element of the array.




Tst_Array VAR word[20]
Counter VAR word



FOR counter=0 to 65534
Tst_Array[17]=counter
gosub Print2LCD
NEXT counter

sayzer
- 25th December 2009, 07:45
Hi there,

What do you have in "Print2LCD" subroutine? If it is not a light speed transportation project, can you show us?

Also,

Why not simplify your code as below?



FOR Tst_Array[17]=0 to 65534
gosub Print2LCD
NEXT Tst_Array[17]

archendekta
- 25th December 2009, 18:41
light speed project, that is funny! ;-)


it just sends the array to a 2x16 lcd. hmmm, maybe i'm missing a modifier here




Print2LCD

FOR Ndx=0 to 18
hserout [ Tst_Array[Ndx] ]
NEXT Ndx

RETURN

mackrackit
- 25th December 2009, 22:18
I do not have my manual with me but what if you change:
Tst_Array VAR word[20]
to
Tst_Array VAR byte[20]

rdxbam
- 28th December 2009, 05:22
hey mackrackit & others

i changed type to byte with the same results.

when array is of type word, and using my debugger i see the element's value as of a word type having 16 bits. so the issue isn't with the array elements. i thinking it is the hserout performing as it is designed to do.

what i'm seeing is the function hserout, and i assume the software version, serout, is sending values up to dec 255 then rolls back to dec 0 and starts the low bits all over again.

going to try some things ... back soon ...

thx

Archangel
- 28th December 2009, 05:26
Tst_Array[Ndx].highbyte, Tst_Array[Ndx].lowbyte ?

archendekta
- 29th December 2009, 06:37
compiler returns this error: This style array syntax not supported

i'm looking at this page now for some pointers,
http://www.picbasic.co.uk/forum/showthread.php?t=4641&highlight=style+array


maybe there is a limitation on the usart for sizes >byte or there is a register config setting i've missed on this 16f88.

i'm looking into it, back later ...

sayzer
- 29th December 2009, 07:16
compiler returns this error: This style array syntax not supported

i'm looking at this page now for some pointers,
http://www.picbasic.co.uk/forum/showthread.php?t=4641&highlight=style+array


maybe there is a limitation on the usart for sizes >byte or there is a register config setting i've missed on this 16f88.

i'm looking into it, back later ...


Then have a word variable like



Temp VAR WORD


Then, modify the print routine as follow.



Print2LCD

FOR Ndx=0 to 18
Temp = Tst_Array[Ndx]
HSEROUT [Temp.LowByte,Temp.HighByte ]
NEXT Ndx

RETURN

archendekta
- 31st December 2009, 07:14
that worked sayzer. thanks.


curious, this is the format for arrays in PBP to get word, longint values through usarts to radios?

archendekta
- 4th January 2010, 08:19
it's working now. now that you helped with the high-low byte. on the receiving end i'm just multiplying the highbyte by a constant and adding it to the lowbyte to get my 16bit value.

many thanks