control parallax lcd with pic16f630, nothing but errors, picbasic pro

Thread Starter

rudyauction8

Joined Jan 27, 2012
250
Here is the code:

Rich (BB code):
define osc 4
 INCLUDE "modedefs.bas"


 do
  high porta.0
  high portc.4
  pause 100
 
   serout2 portc.4, 24972, ["abcdefg"]
 
  low porta.0
  pause 500
 loop
very very short and simple, yet all that comes up is a bunch of "&"'s, and at that only when the output is inverted. With it set to true, I get nothing. porta.0 is an LED to tell me when the next string is sent, portc.4 is the LCD. I've tried a half dozen ports, my baud rates are correct, checked a dozen times, set configs in programmer, everything works except the data doesn't go through. I've been using this chip to read/write an i2c eeprom, it works fine. Any ideas?

Yes I know my code is bad, it's just to test the connection before I add the LCD to a real program.
 

Thread Starter

rudyauction8

Joined Jan 27, 2012
250
anyone?? and I turn the serial port high for 100ms before sending the data because that's what it said to do in the datasheet, it does the same thing with or without that line of code. And the LCD works fine on my bs2, so its definitely something in the pic setup or code.
 

nickelflipper

Joined Jun 2, 2010
280
Not familiar with PicBasic Pro, but it looks like the bit timing is off. If 24792 is supposed to be the baud rate, then I have to say it is really odd. Two flyers at what it might be:
1) The lcd header file needs a higher clock rate? Try external 8Mhz-20Mhz clock.
2) Manually adjust the baud rate to see if output can be improved?

I remember a person trying to get the parallax lcd going in another forum, different compiler, and had similar problems. Not sure if it ever got resolved. Good luck.
 

Thread Starter

rudyauction8

Joined Jan 27, 2012
250
The 24792 baud is 2400 baud inverted open. True driven is 396. I was trying every possible setting, the closest to working was driven inverted. The picbasic manual states that 4mhz clock speed is OK for 4800 baud or less, I lost the osccal value for the internal oscillator during programming (I'm new to this), I left it at 3FFF. Would that cause problems? I do have some 20mhz +-0.2% ceramic resonators in the mail, they should be here within a few days. I also have a few other pics I could try that don't use osccal values, one runs at 8mhz.

Is it possible that it uses 8 data bits and a 9th parity bit? just found that option, haven't tried it yet.
 

nickelflipper

Joined Jun 2, 2010
280
Clock frequency should not be a problem at that low of baud rate. Losing the Oscal value could be a problem, as that could account for +/- 15% error. The Pickit 2 programmer can re-establish the Oscal value for you automatically. Check if your programmer can do the same.

Good idea to try another chip. Doubt that parity bit is being used. Inverted usually means you are running Tx/Rx through a Max232 chip?
 

Thread Starter

rudyauction8

Joined Jan 27, 2012
250
My programmer can only program, I got it for $10. That's what got me into these chips. I'll try another chip. What's the osccal range so I can try a bunch of random values if one of my other chips works? And are there any easy to use serial LCDs that work with these for under $20?
 

nickelflipper

Joined Jun 2, 2010
280
Good that it works on the 16f627.

If the programmer doesn't have the window or tools to set the Oscal directly Then:
I would do so some search on this, or the Microchip forum, for restoring the Oscal by programming? I am sure it has been asked before, and done before. Personally, I've just taken the easy way out with the Pickit2

Just a guess:
Rich (BB code):
call  0x3FF ; last program memory location
movwf 0xCF  ; Guess of OSCAL
 

Thread Starter

rudyauction8

Joined Jan 27, 2012
250
@nickelflipper:
Yes it has been done before, but every thread I found involved a scope (???), pickit 2 or 3 or other tools that I don't have. Either way I got it by increment the OSCCAL register by 4 until my LCD worked, then it displayed the OSCCAL value for me. It probably isn't the best value, but the next speed that my LCD supports requires an external clock source anyway and I don't have any other use for rs-232 serial connections.

@JohnInTX:
Will that code work in the picbasic compiler? I have no knowledge of assembly but if it will work I have 2 other pics with erased osccal values that I wouldn't mind restoring and the program I made doesn't seem to increment right, it took 15 minutes at 2 increments per second to get a reading.
 

ErnieM

Joined Apr 24, 2011
8,377
rudy: Just stick in a line in your basic program like so:

Rich (BB code):
OSCCAL = {whatever magic number you discovered}
 

JohnInTX

Joined Jun 26, 2012
4,787
rudy: Just stick in a line in your basic program like so:

Rich (BB code):
OSCCAL = {whatever magic number you discovered}
True enough but for chips that haven't been clobbered there should be a way to get the factory calibrated value at 3ffh and put it in OSCCAL. Check the compiler docs. I don't use picbasic so don't know but that's what has to be done in the code after reset to calibrate the oscillator. I would expect that the compiler would generate the code in the startup but don't know.

If its not documented, write a dummy program and look at the disassembly window to see if something like the previous assembler code is present in the startup routine.

Have fun.
 

Thread Starter

rudyauction8

Joined Jan 27, 2012
250
rudy: Just stick in a line in your basic program like so:

Rich (BB code):
OSCCAL = {whatever magic number you discovered}
I entered:
Rich (BB code):
OSCCAL = 0
OSCCAL = OSCCAL + 4
pause 500
and displayed it on my lcd.

and got a working number after ~15 minutes. What I'm thinking is that the first 2 #s are a memory address and the second 2 are the actual OSCCAL number, which if true will make figuring out my other 2 chips a lot easier.
 
Top