usart rs232

General discussion on mikroPascal.
Post Reply
Author
Message
trigstig
Posts: 33
Joined: 05 Sep 2006 09:07

usart rs232

#1 Post by trigstig » 20 Jul 2011 21:09

can some one help, i would like to send data from the terminal tool to the pic16f877a, when the pic receives the data
one byte at a time i need to write it to the eeprom similar to this

for x := 1 to 20
begin
Eeprom_write(x,Usart_read);
end;

all i am getting is one byte written to all addresses how do get "hello world"
split over the eeprom addresses
ie
address 1 = h
address 2 = e
address 3 = l
etc etc..

thanks in advance

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: usart rs232

#2 Post by janni » 20 Jul 2011 22:38

trigstig wrote:all i am getting is one byte written to all addresses
No wonder, your code does exactly this. What is Usart_read? A char, a string?

trigstig
Posts: 33
Joined: 05 Sep 2006 09:07

Re: usart rs232

#3 Post by trigstig » 21 Jul 2011 07:46

usart_read is taken from the example given it started of recieved_byte := usart_read after data ready test

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: usart rs232

#4 Post by janni » 21 Jul 2011 12:03

trigstig wrote:usart_read is taken from the example given it started of recieved_byte := usart_read after data ready test
Then it's of byte type and your code writes the same byte to all EEPROM cells.
when the pic receives the data one byte at a time i need to write it to the eeprom
Unless you send single chars only, that's not possible as writing byte to EEPROM takes more time than receiving a byte (at least for reasonable serial communication speed).
You'd have to receive whole message first and collect it in a string or array of chars and only then store it in EEPROM.

You could try to use UARTx_Read_Text procedure which will wait for whole message.

trigstig
Posts: 33
Joined: 05 Sep 2006 09:07

Re: usart rs232

#5 Post by trigstig » 23 Jul 2011 17:58

thats ok but the method you describe "UARTx_Read_Text" only allows 20 char i need to split 120 bytes
unless theres a way of increasing the size.

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

Re: usart rs232

#6 Post by Dany » 23 Jul 2011 19:52

trigstig wrote:can some one help, i would like to send data from the terminal tool to the pic16f877a, when the pic receives the data
one byte at a time i need to write it to the eeprom similar to this

for x := 1 to 20
begin
Eeprom_write(x,Usart_read);
end;

all i am getting is one byte written to all addresses how do get "hello world"
split over the eeprom addresses
ie
address 1 = h
address 2 = e
address 3 = l
etc etc..

thanks in advance
You should check first (with e.g. function UARTx_Data_Ready) if a byte did come in via uart before writing it to eeprom.
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: usart rs232

#7 Post by janni » 24 Jul 2011 11:56

trigstig wrote:thats ok but the method you describe "UARTx_Read_Text" only allows 20 char i need to split 120 bytes unless theres a way of increasing the size.
Then you'll have to do it yourself, receiving and storing the message in a string or array of chars byte-by-byte. Only then you may store it in EEPROM.
And take into account that storing 120 bytes may take as long as one second :!:

trigstig
Posts: 33
Joined: 05 Sep 2006 09:07

Re: usart rs232

#8 Post by trigstig » 25 Jul 2011 18:53

i will try a few things let you know if i am succesfull. thanks for input.

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: usart rs232

#9 Post by janni » 25 Jul 2011 22:01

You could switch to the PRO version of mP. UARTx_Read_Text allows there for longer strings.

Post Reply

Return to “mikroPascal General”