PDA

View Full Version : Reading large data via RS232



Robson
- 26th August 2007, 23:55
Now i have stuck with processing in RS232. I want to send a large string about 2kB. The string starts with $FF and ends with $FF and between is my data.
I tried with hserin and hserin2 [wait($FF), STR B0\96), but after this hserin stops. Itīs waiting for another $FF input.
The array to reserve is max limits to 96Bytes "B0 VAR BYTE(96)". How to code something like this for 2kB of data ?

thx Rob

BigWumpus
- 27th August 2007, 00:52
Maybe it's better to use HSEROUT for sending data instead of HSERIN ;-)

What do you realy want to build ?

Robson
- 27th August 2007, 10:10
I will send from PC (via SerialCom) a huge packet of data, beginning with $FF and ending with $FF.
The PIC should receive the packet and store it to the FRAM.
I tried it like above, but i receive max 96 Bytes and then waiting for another $FF. I just need to say to the PIC, when $FF is incoming, then read the data and store till another $FF instruction is following.

mackrackit
- 27th August 2007, 10:38
Have you looked at this http://www.picbasic.co.uk/forum/showthread.php?t=6982

Bruce posted it yesterday, can not wait to try it myself.

inse
- 28th August 2007, 12:31
Hi Rob,

if you want your program to reiceve the 2k of characters and then store them to the FRAM, you would have to buffer them in the RAM.
Which PIC are you using currently?

Regards,

Ingo

BigWumpus
- 28th August 2007, 12:36
If you want to receive 2k Data inside two start-stop-signs, you can't use one PBP-command, you have to write a programm !

like this:
Repeat
Read 1 character
Until this is the start-character

ende=0

repeat
Read 1 character
if "this is the end"? then
ende=1
else
store the character
endif
until ende=1

And don't forget to use the hardware-UART !

Robson
- 28th August 2007, 13:37
I have an USART MAX232. Itīs on my dev. board included.
I know how you mean to realize that, but i have to trigger the RX Channel with the incoming data from the computer? I use 9600Baud = 960 Bytes included start & stopbit.
I think without serin commands can it be difficult to catch the bytes for the right time, maybe the input will shift for many bits!

BigWumpus
- 28th August 2007, 14:34
I have an USART MAX232. Itīs on my dev. board included.

No !
The MAX232 isn't a USART. The USART is a part of the PIC. Just look, if the Rx- and Tx-Pins are propperly used.


I know how you mean to realize that, but i have to trigger the RX Channel with the incoming data from the computer?

No,
after activating the USART, it will receive any character.


I use 9600Baud = 960 Bytes included start & stopbit.

Yes,
every second !


I think without serin commands can it be difficult to catch the bytes for the right time, maybe the input will shift for many bits!

Without using HSERIN it will be impossible !
You have 1/960 seconds to store a character.
Writing to a EEPROM needs 10ms (10 times more) to complete the write-cycle.

You have to store the data in RAM.

If you are good - you can write 1 page (maybe 128 Bytes) to a serial eeprom and start the write-cycle and maybe 15 characters later you can start to submit the next page, so you must only buffer 15-30 characters.

Using hardware-USART with interrupts will be much better.

Robson
- 28th August 2007, 19:37
I prefer to use FRAMīs. Then there will no troubles about writing to eeprom.