PDA

View Full Version : why this doesn't work?



strasni_betmen
- 4th August 2008, 17:49
using pbp246.
pic16c84 over max232 to pc rs232 interface (tested, working - i tested the circuit with simple flashing LED example).
when i run hyperteminal, i get strange output instead "U"s.

code:

DEFINE DEBUG_REG PORTB
DEFINE DEBUG_BIT 6
DEFINE DEBUG_BAUD 115200
DEFINE DEBUG_MODE 0
DEFINE OSC 8
DEFINE DEBUG_PACING 3000
loop:
DEBUG "U"
Goto loop

what am i doing wrong?
is 115200 baud possible with DEBUG and 8MHz osc? how?

skimask
- 4th August 2008, 17:56
And I'm guessing you haven't tried any lower baud rates?
(See App.A in the PBP manual)

Read this thread and the thread linked in the middle...
http://www.picbasic.co.uk/forum/showthread.php?t=5892&highlight=debug+baud+rate

strasni_betmen
- 5th August 2008, 17:31
9600 baud written in PBP - works, 57600 - works partially(has some garbage).
but assembler code from Bruce works at 11520baud, 4MHz.

one more question - 20MHz oscilator can definetly do software 115200 baud input and output with SERIN and SEROUT?

thanks for your effort!

skimask
- 5th August 2008, 18:33
one more question - 20MHz oscilator can definetly do software 115200 baud input and output with SERIN and SEROUT?
Is that a question or a statement?

Bruce
- 5th August 2008, 18:41
If you need 115200 bps use DEBUG with a 20MHz oscillator. DEBUG uses the PAUSEUS
library function.

To figure out what data rate DEBUG will work with at a given oscillator speed use this;
(1000000 / (DEBUG_BAUD)) - (52 / (OSC)). Just drop remainders and keep the whole #.

OSC is how you define it not the actual oscillator speed. I.E. 4MHz would be 52/4 and not
52/4000000.

1000000 / 19200 = 52
52/4 = 13
52-13=39

Now try 38400 bps at 4MHz.

1000000 / 38400 = 26
52 / 4 = 13
26-13 = 13

The result is less than the minimum PAUSEUS time period for 4MHz, so it won't work at
38400 bps with DEBUG.

The value you end up with after the math should not be less than the minimum PAUSEUS
time period shown in your manual in the PAUSEUS section.

At 4MHz 19200 is the best you'll get with DEBUG.

With SERIN2/SEROUT2 use the calculation shown in the manual. (1000000/baud)-20. The
result has to be positive for it to work.

strasni_betmen
- 3rd September 2008, 21:02
what pic do you recomend to do a hardware serial communication at 115200 baud?
nothing else is of importance.

Bruce
- 4th September 2008, 14:42
I would think any PIC with a hardward UART. Check the data sheet. There are calculations
showing data rates & settings based on various oscillator speeds.

strasni_betmen
- 4th September 2008, 15:56
is the scheme in the attachment good enough to do asynchronus serial communication from pic16f877 to nokia 5110?

sory if this is not the place to ask but since it is all related i figure it wont hurt nobody! :) thx to anybody who helps!