PDA

View Full Version : HSERIN seems to fail and I can't see WHY



Jumper
- 13th August 2006, 15:39
Hi,

Baudrate 9600 just for safe.

I have a need to read a String of 256 characters from a PC and I would like to use the HSERIN command. There is a lovely little modifier STR that would allow me to do this. To test this I turn on a LED when waiting for the String, and as soon as I pass this line in my code I turn the LED off.

LED=1
HSERIN [STR RxData\64]
LED=0

First I tried with a shorter string of 64 chars and it works nice BUT when I increase the number to RxData\256 the command behaves in the same way as if I would have set it to \0. The led flashes and that's it, even if I send nothing to the PIC. It just skips the command....

I am using a 18F4620 and according to the "Manual" arrays used in 18-series can span Banks and are ONLY "limited in length by the amount of memory"


Bug or feature or did I miss some important part in the Holy Book of Pics?

/j

Darrel Taylor
- 13th August 2006, 19:40
Hi Jumper,

After looking at the PBPPIC18.lib file, it appears that the STR modifier is limited to a single byte for the "digit count". So 255 will be the maximum.

See if this helps...
HSERIN [STR RxData\255, RxData(255)]
<br>

Jumper
- 14th August 2006, 09:04
Thanks for the answer and your idea works, it it any different if I use that way or:

for n=o to 255
HSERIN [RxData(n)]
next n

except it compiles in different size?

by the way,

I was trying to load a Byte from the RxData array into the lowbyte and high byte of a word array "C_Data(x)". What would be the best way of doing (since this is not allowed)?

C_Data(x).Lowbyte=RxData(n)
C_Data(x).HighByte=RxData(n+1)

I solved this loading with using a Melanie suggested method "C_Data.lowbyte(i) =RxData(n)" but this requires that you adresses the C_Data.Lowbyte(i) not using the word count but the position of the byte in the word array so the Highbyte iadresses as C_data.Lowbyte(i+1).

I couldn't even get a temporary word variable to work but that could have been because of the time of the day.

This should work right??

Temp.Lowbyte=RxData(n)
Temp.HighByte=RxData(n+1)
C_Data(i)=Temp




Not that user friendly ;-) (at least not 3 am)

/j

Darrel Taylor
- 14th August 2006, 17:51
Thanks for the answer and your idea works, it it any different if I use that way or:

for n=o to 255
HSERIN [RxData(n)]
next nThat'll work just as well. Wouldn't be the case with SERIN2, but with HSERIN it's fine.


I was trying to load a Byte from the RxData array into the lowbyte and high byte of a word array "C_Data(x)". What would be the best way of doing (since this is not allowed)?

Here's another possibility...
C_Data(i)=RxData(n) << 8 + RxData(n+1)or...
RxData VAR BYTE[256]
RxDataW VAR WORD EXT
@RxDataW = RxData

; -- then later on ---

C_Data(i) = RxDataW(n/2)

But the second one assumes the data in the byte array is aligned to word boundaries, which may not be the case.
<br>