Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

12f629 comms on usb2rs232 cable

Status
Not open for further replies.

cybersky

Member
Hi I wrote a small app to output text to the pc serial port. I am using all the available pins on the little chip so i cannot use ext osc. I have build a max232 circuit for the pic 2 PC comms. BUT i get garbage from the chip. It 'looks" like it is outputting but it is not legible. I tried all baudrates (slower - slowest). I have noticed that if i connect pic tx direct to usb(serial) rx i get the same mumbo jumbo as thru the max232. Do not have PC with serial port. Any Ideas? i used the serout and seroutinv functions. I remembered to save the oscal value and wrote that in manually after i loaded the .hex file in winpic 800.
 
You need to read the osccal value from the location (it isn't placed in by itself)... I usually look at the value previously... then load it manually.. OSCCAL = 0x45 ( or whatever it is)

The procedure to load the osccal IS in the datasheet.....REMEMBER that this is not modelled in oshonsoft.. so the program won't simulate properly if you try to read the osccal value.
 
i do the following:
1. new pic in prgmr,
2. read pic to get oscal value. write it down - mostly just remember
3. load hex file then manually change oscal location to have same value as written down from the read.
4. write all.

is that ok? or is oshonsoft changing it during the write (by having some code in the hex?).
 
There is an OSCCAL register located at 0x90 .... The value required is located at 0x3FF.... if you write OSCCAL = (the value situated at 0x3ff) it should work for you.

John... He has the value.. He needs to store it in the OSCCAL reg
 
T
John... He has the value.. He needs to store it in the OSCCAL reg

That may be true, but the first two steps of his plan of action in Post#3 immediately preceding my post implied he either didn't have it or wasn't sure of its value.

In any event, it might be useful for him to know how to adjust and/or recover the factory value.

John
 
Hi I do know the oscal value and i simply replace it after i load my hex, should i have to set it in code aswell? for the sake of more info i am using gp2 as my tx pin.
 
Last edited:
I been playing with them 8 pin pic and for some reason they like TX to be on GP0 better then any of the rest of the pins. I think its a read write modify problem. That's why it's a good idea to use shadow copy of GPIO

The Op really needs to post his code the comparator maybe be still set.
 
so is there a specific line of code to add to my basic code? I only have
Code:
 config gp2....
serout gp2, 1200, "hello World - 1200", crlf
serout gp2, 2400, "hello World - 2400", crlf
serout gp2, 4800, "hello World - 4800", crlf

so i will set the oshonsoft pc serial port interface to 1200 baud, switch on and check what come on the screen. then i change the baud to 2400 and so on. a bit easier that changing the baud in the code and reburning everytime. so it is effectively 1 line of code. I suspected some prob with freq. but i have even set the serout_delayus to 5000 (was 1000) maybe i should try a higher value?
 
I do not have that line in my code.
OSCCAL = ??
-

I have entered the
OSCCAL = x40 (3430)

Compiled new hex and VOILA ! you guys are the best!
CASE CLOSED. So far 1200 and 2400 baud is OK. Fast enough for what i need!

THANKS THANKS THANKS

p.s Perhaps this should be added to the oshonsoft code snippets section ? very useful info
 
Last edited:
View attachment 61603

hi Ian , here is what i have in winpic after the read. I looked at the value on the right which is why i got "40". But are you saying i should stick to the value on the left and take last two "30"?
2400 is plenty for now BUT higer bauds will always be a benefit. Thanks
 
The value is 0x30..... The right pane shows ascii representation ie. 3430, 34 in ascii is '4' and 30 is ascii character '0'. 34 is the command and 30 is the literal (the value you need)
 
Last edited:
ok, thanks for that info. Knowing these "small" things really makes things seems very easy and certainly takes the frustrastions out of the fun of making things! Thanks again
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top