Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] PIC16F88 Oscillator problem

Status
Not open for further replies.

jrd660

Newbie level 2
Joined
Dec 4, 2010
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,309
Gday all.
New here to the forum and need some assistance.
I'm programming a 16F88 for servo signals based on 20ms frame rate and 1-2ms mark time (For an ESC brushless motor control). So far, the success has not been good. As a cut down basic version of the code (I cut away all the extra parts of code to get just the basics of timing and an output to a pin for testing), here's what it looks like

TRISB = %00000000
begin:
PORTB.4 = True
WaitUs 1000
PORTB.4 = False
WaitUs 19000
Goto begin
End

It's simple enough: Port high, wait 1ms, port low, wait 19ms, repeat....
Programmed with OshonSoft, chip burned with PICkit 2 and run on a breadboard from a fixed 5V line on a variable PS.

Configuration Bits:
Flash program code protection - OFF
CCP1 multiplex selection - RB3
In-circuit debug - Disabled
Flash program write protection - OFF
EEPROM protection - OFF
Low voltage ICSP - Disabled
Brown-out reset - Enabled
RA5/MCLR selection - Digital Input
Power up timer - Enabled
WDT - Disabled
Oscillator selection - INTOSC
Internal/External switchover mode - Disabled
Fail-safe clock monitor - Disabled

Here's the problem... The Mark/Space timing is completely wrong. (First apparent when trying to use TMR0 interrupt)
Here's the details -

test 1:
1 Mhz Internal Clock:
Total simulated time = 20056uS, measured mark time = 0.024Secs, measured mark/space time = 0.616Secs

Test 2:
4 Mhz Internal Clock:
Total simulated time = 20014uS, measured mark time = 0.12Secs, measured mark/space time = 2.48Secs

Test 3:
8 Mhz Internal Clock:
Total simulated time = 20007uS, measured mark time = 0.28Secs, measured mark/space time = 4.96Secs

The same code compiled and run on a 16F628A work perfect.
I'm guessing I haven't set the 88's (I've tried 5 of them, presumably from the same manufacture batch) and they're all the same.
Not new to PIC programming, but I'm not an expert in them. I am new to 88's, so I've probably missed something along the way.

I'd appreciate any clues that someone may have.
Thanks
 

The software you're using to write/compile the program creates assembler code for delay routines based on the device's oscillator. Did you tell the software which oscillator you intend to use?

There's usually a config keyword specific to the software you're using that tells which clock SPEED you're using.
 

Thanks for your suggestion Jumper2high. After much hair-pulling I finally managed to get it sorted and as expected, it was my own silly fault.
I hadn't set the OSCCON register (never used it before on other chips) so it seems the clock wasn't running at the full frequency. My usual frequency selection is entered into the simulator and that's where it ends, but not on the 88 it seems. I'm not sure if it's 'normal' for the simulator to clock at full speed or if it's a bug. Once I set the register to an 8Mhz clock and ran on a micro, a perfect 20ms pulse appeared on the CRO.
Phew, I need a drink after that one, and make a mental note to SET THE REGISTER!!!
Thanks again
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top