PDA

View Full Version : PBP "USART.BAS" Doesn't Work



Corey
- 9th October 2003, 03:09
Hi Everyone,

I've been using HSEROUT and HSERIN with no problems. That being said, I'd like to make my program as lean as possible. I'd also like to be able to do some small background tasks while I wait for characters.

So far I've been able to accomplish this with HSERIN and a time-out. Basically, I look for a character and, after 1ms, if there still isn't a character I go do something else and then look again.

To do all of the things I'd like to do and still keep my "ear" to the receive line, I need to get down to the nuts & bolts of the USART a bit more.

Has anyone been able to make "USART.BAS" from the PBP "Sample" folder work?

I loaded it as is and all I get is garbage. I'm using the same oscillator (20MHz) and I have my terminal program set at 2400 baud.

If anybody can give me a hand here that would be great!

I've attached the actual code to this post in case you don't feel like looking for it in the PBP folder.

Thanks!

mat janssen
- 21st October 2003, 12:29
I also had problems with this and I used a 16f876 with a bildin usart.
now i use an other instuction and never had any problems with the uart anymore.
here is an example: 2400 baud
DEFINE OSC 4
DEFINE SER2_BITS 8
TRISC = %10010000
pinin VAR PORTC.7
pinout VAR PORTC.6
B1 var byte

for taking data in I use:

SerIn2 pinin,396,[B1]

The data will be put in B1
sending data to device

SerOut2 pinout,396,[B1]

succes