PDA

View Full Version : Define osc 8 not working on 12f683 - wondering if Its related to include files?



dw_picbasic
- 8th February 2014, 17:00
Hi gang,
I've been playing with a 12f683 in 4mhz mode and sending results to a serial LCD using "SEROUT pin, T9600, ["text here"]

works fine.

But then I tried bumping the internal osc to 8mhz

OSCCON = %01110111 ' internal oscillator at 8 MHZ
define osc 8

The oscillator frequency is definitely changing
But the "define osc 8" command looks like its being ignored by PBP3.

I put an Oscope on the serial clock pulse-width to check.
And with our without the "devine osc 8" there is no change.

Where should I look for troubleshooting this?
I'm using Pickit2 as the programmer.

Big Thanks!!
Duane

HenrikOlsson
- 8th February 2014, 17:15
Hi Duane,
The manual would be the first place to start when troubleshooting this particular problem :-)
Define is a case sensitive keyword, ie osc is not the same as OSC. So, try define OSC 8.

/Henrik.

rudyauction509
- 9th February 2014, 10:59
THANK YOU! I've been having the same problem for the past year, just adjusted timing manually and never bothered to figure it out.

Heckler
- 9th February 2014, 16:00
Just make sure you enter any "DEFINE" statements as all CAPS.

They are case sensistive.

HenrikOlsson
- 9th February 2014, 16:19
And again, it's WHAT you trying to define that's case sensitive, not the word define itself


DeFiNe OSC 8 ' works
define OSC 8 ' works
DEFine OSC 8 'works
DEFINE OSC 8 ' works
DEFINE osc 8 'does not work because OSC is what's case sensitive.

/Henrik.

dw_picbasic
- 9th February 2014, 21:56
Actually, I'm using Micro Code Studio editor and it auto-magically changes the case of everything to what it likes.
So I tried typing all upper case and MCSE just changes it to lower case.
I've looked in the PBP3 manual and don't see anything that would give a hint.
I think I'll try to email Mel Labs if they have the time to answer.
I'm sure they've seen that before.
They designed the compile code, so I would hope they would know what I should be looking for.
I wonder if there is something in the include file that is over-riding the define statement.
I'll post what I find out.
Thanks my friend :-]

HenrikOlsson
- 9th February 2014, 22:44
Hi,
Actually, you can change the way MCSP formats the code by going to View -> Editor Options -> Highlighter but that can be a bit misleading because it's actually only how MCSP displays the code on the screen IN MSCP, if you open the code in Notepad or whatever it'll be exactly as you typed it - something to watch out for in other words.

If you look at section 2.3.3 in the PBP3 manual you'll find

For the user familiar with Assembly Language, the major clue to understanding is that DEFINEs in PBP are converted literally to Assembly Language #DEFINE directives.
For the practical PBP user, there are a couple of fundamental points to consider:
1) DEFINEs are CASE SENSITIVE!
2) Specific DEFINEs are generally associated with PBP commands. The command pages will describe how the relevant DEFINEs affect the operation of each command.

This has been covered multiple times in the forum but again, the word define is a PBP command/keyword and PBP is not case sensitive so it can be either case DEFine, defINe, DEFINE, define, doesn't matter. What comes AFTER DeFiNe is passed directly the assembler and the assembler (MPASM) IS case sensitive. PBP's library routines are written in assembly and uses the OSC setting/value/variable/definition/whatever to calculate software delays, baudrates etc etc etc. So when you need to tell the compiler that you're using another oscillator frequency you need to define OSC not osc or Osc, they are three different things and the library routines only know about OSC - not osc or Osc.

/Henrik.

AvionicsMaster1
- 9th February 2014, 23:34
As many times as this DEFINE in particular gets brought up you'd think MeLabs would at least give you an error during compile if the two defines XXX don't match. Seems like it should generate some kind of error.

Darrel Taylor
- 10th February 2014, 00:40
You can DEFINE anything you want for use with your assembly language routines.
PBP has no way to know if you are using 'osc' in your routines, or if you didn't capitalize 'OSC' for PBP.

It is unfortunately up to you to get it right.

AvionicsMaster1
- 10th February 2014, 02:49
Never good to rely on lowest common denominator. That reliance means this thread will be recreated many more times.

dw_picbasic
- 12th February 2014, 04:04
Henrik was right in his original post on this.
It just occurred to me ***DUH*** that just because the editor automatically makes "define" into lower case, doesn't mean the OSC is supposed to be lower case as well.

With MicroCode Studio the only syntax that works is "define OSC 8"

Nice to have the 8mhz clock running for more fun experiments.
BTW:
I just got a couple 18F2550 chips.
Looking forward to playing with them!!! :-]