PDA

View Full Version : 12F675 cant serout to PC



ruijc
- 2nd December 2007, 20:53
Hi all,

I have here a 12F675 and i was using it read a LM35 and send out temp to PC via serial port ( not using MAX232 ).

The problem is that i'm facing comunication problems.
I cant get the pic to send a correct word out !

All i get is rubbish.

I've seen someone here with the same problem but it was resolved with XT->HS change !

I've tryed so many things ( speed, xtals, etc ) and nothing works :(

Here's the code:

@ DEVICE PIC12F675, MCLR_ON
' Master Clear Options (Internal)

@ DEVICE PIC12F675, PROTECT_OFF
' Program Code Protection

define osc 4

Include "modedefs.bas" ' Include serial modes

define osc 4

ANSEL = %00000000 ' Set analog ports to digital mode

CMCON = %00000111 ' Turn off comparator

'TRISIO = 00001000 ' designate gpio.0,1,2,4,5 as output 3 as input

WPU = %00000000 ' Disable pull-ups
TRISIO = %00000 ' Set all I/O's to outputs

out:

low gpio.2

Serout2 GPIO.1,396,["396",10,13] ' check if this works
pause 200
Serout2 GPIO.1,84,["84",10,13] ' or this
pause 200
Serout2 GPIO.1,188,["188",10,13] ' or this
pause 200
Serout2 GPIO.1,16572,["16572",10,13] ' or this
pause 200
Serout2 GPIO.1,N2400,["N2400",10,13] ' or this
pause 200

high gpio.2

pause 500

Goto out

thanks for the help
.

mister_e
- 2nd December 2007, 21:49
add that line at the top of your code

DEFINE OSCCAL_1K 1
this should help

ruijc
- 2nd December 2007, 23:08
Thanks for the tip Mister-e

but isnt this for when using only the internal osc ?

i'm using an external 4Mhz xtal

.

mister_e
- 2nd December 2007, 23:35
Yup and i missed it...

What capacitor value did you put on your Crystal? 15-22pf?

what happen if you remove the MAX232, and use inverted mode for your baudrate???

With the MCLR_ON, it mean you use MCLR, so i hope this pin is tied to Vcc?

Clean psu, decoupling caps here and there?

Did you also tried with the internal OSC?

I don't see anything wrong in the code...

ruijc
- 2nd December 2007, 23:35
I have tryed that but if i use that line it does not work ( doesnt send data nor the led in gpio.2 blinks )

.

mister_e
- 2nd December 2007, 23:37
what happen if you change MCLR_ON to MCLR_OFF?

Are you sure it's a 4MHZ crystal?

Can you measure it with a scope?

ruijc
- 2nd December 2007, 23:43
I'm not using any Max232

About the MCLR, when on i hooked it to vdd, also tryed off and result is the same.

The caps for the xtal are both 22pF

I'm using the Serin program to get the data from serial

.

ruijc
- 2nd December 2007, 23:45
i can try using the internal osc...but will have to use MCLR on or i will lock my pic :S

IC-Prog has 2 choices...

INTOSC GP4

and

INTOSC CLKOUT

which one may i use ?

mister_e
- 2nd December 2007, 23:45
I'm not using any Max232
AH CRAP, i really need new glasses... so just change your SEROUT2 baud constant to use inverted mode... and it will work


baud Serout2
---- -------
9600 16488
4800 16572
2400 16780


with 1-10K resistor in serie, this have to work.

I would suggest you to use DEBUG, it use less code space and may work on higher baudrate with slower crystal speed.

ruijc
- 3rd December 2007, 00:11
The SEROUT2 baud constant table did not worked as well...

but...

using DEBUG worked 5*****

I guess it's because the low speed xtal

Thanks once again Mister-e ;)


.