How to red a string using SUART?

General discussion relating to the library modules supplied with the compiler

Moderators: David Barker, Jerry Messina

Post Reply
Francesco.C
Posts: 41
Joined: Thu Feb 26, 2009 6:54 pm
Location: UK

How to red a string using SUART?

Post by Francesco.C » Sat May 30, 2009 6:28 pm

Hi guys,
I have been using the USART command 'WaitForStr' to send a string from windows terminal.

Now, as my project has developed, I cannot use the same port pins.

So I decided to use SUART and declared 'UART.SetRX(PORTB.2)'.

However I have not managed to find the equivalent to 'WaitForStr'

I have looked in the help file and done some research on the forum, but I had no luck.

Can anyone give me an example of how to send a string and verify it?


Regards

Francesco C.

Doj
Posts: 362
Joined: Wed Apr 11, 2007 10:18 pm
Location: East Sussex

Post by Doj » Tue Jun 02, 2009 8:11 pm

If you look at post 7 here http://www.sfcompiler.co.uk/forum/viewtopic.php?t=645

You could modify that to work with soft usart.

You will need to use a known time when the data is coming or use the idea in that post of waiting for the rx pin to change state and jump to the receive routine.

If you load the characters into a string (or an array) and do a compare against your wanted data then it will be fine.

Do not expect to get very high speeds with the soft usart especially on low crystal speeds, what you are doing is by far better suited to the real usart, an interrupt driven routine is easy and super reliable, can you not change the other use of these pins and stick with hardware usart, might save you a great big pile of dead code.

Francesco.C
Posts: 41
Joined: Thu Feb 26, 2009 6:54 pm
Location: UK

Post by Francesco.C » Wed Jun 03, 2009 4:24 pm

Thank you for the advice. Iwill consider changing my hardware design.

Regards

Francesco C.

Post Reply