PDA

View Full Version : HPWM issues on 16F88



George
- 31st October 2005, 20:46
I've looked through data sheets, manual and searched the other files on here - but can't make sence of why this isn't working - probably a complete lack of understanding.

ANy help setting up the chip would be very thankfully recieved - thanks :)

Here is the code so far:
@ DEVICE INTRC_OSC, WDT_OFF, MCLR_OFF
DEFINE OSC 8
DEFINE CCP1_REG PORTB 'HPwm 1 pin port
DEFINE CCP1_BIT 1 'HPwm 1 pin BIT
TRISA = %00000011 'Set I/O
TRISB = %00000000 'Set I/O
CMCON = %00000111 'Disable analog comparators
ANSEL = %00000001 'Set PORTA.0 analog rest digital
ADCON1 = %10000000 'Right justify result
OSCCON = %01110000 'Set internal osc to 8MHz
speed VAR WORD

speed = 127

Start:

Pause 1000

Pwr = 1

GoSub ReadVals

HPwm 1,speed,2000

blah blah blah

sougata
- 1st November 2005, 18:38
Hi there,

If you need to configure the HPWM manually then this tiny utility may help you.

You will need the VB runtimes.

Regards

George
- 1st November 2005, 18:39
Thanks, tho can't seem to make it run - it says "component 'TABCTL32.OCX' or one of it's dependencies not correctly registered: a file is missing or invalid.

I tried all yesterday different combinations, but still nothing, anyone else got a clue as to what I might be doing wrong? I think I'm slipping up on pin select but not sure

Thanks

sougata
- 1st November 2005, 18:47
Hi there,

Try changing the speed variable to a BYTE !! Or just hardcode a 127 (50% duty cycle).

Did you use an oscilloscope to check for the 2KHz?

Regards
Sougata

Bruce
- 1st November 2005, 18:52
On the PIC16F88, hardware PWM is not on RB1. It can be on RB0 or RB3 depending on how you configure the CCPMX config fuse bit.

George
- 1st November 2005, 19:10
Yeah i did use a scope, will try doing it hard tho.

Bruce, does that mean i go pwm 0,127,2000?

You said to set it up with the CCPMX register - I'm a bit of a beginner and have no idea how to do that, I did see it in the datasheet - but unfortunatly they rn't datasheets for dummies. I used this as per pbp manual:

DEFINE CCP1_REG PORTB 'HPwm 1 pin port
DEFINE CCP1_BIT 1 'HPwm 1 pin BIT

Bruce
- 1st November 2005, 20:20
Hi George,

PBP has default config fuse settings in each device header file. For the 16F88 look in your 16F88.inc file in your PBP directory.

Each PIC family has a device specific header file that contains these default settings. Looks something like this;



NOLIST
ifdef PM_USED
LIST
include 'M16F88.INC' ; PM header
device pic16F88, hs_osc, wdt_on, lvp_off, protect_off
XALL
NOLIST
else
LIST
LIST p = 16F88, r = dec, w = -302
INCLUDE "P16F88.INC" ; MPASM Header
__config _CONFIG1, _HS_OSC & _WDT_ON & _LVP_OFF & _CP_OFF
NOLIST
endif
LIST
If you're using the default PM assembler, the first section is used at compile time to set default config fuse settings. With MPASM, the 2nd.

Assuming you're using the PM assembler, you can change or over-ride these default settings by adding your own config fuse settings to your code like this;

@ DEVICE INTRC_OSC, CCPMX_OFF, MCLR_OFF, LVP_OFF, WDT_OFF
' CCPMX_ON = PWM ON B.3, CCPMX_OFF = PWM ON B.0
' CCPMX is the CCP multiplex config option

Or simply change them with your programmer software before burning your code into the target.

There are several threads on config fuse settings here, so I won't go into details rehashing something that's already here, but that should get you started.

rhino
- 1st November 2005, 20:58
I can understand your frustration with the datasheets George. I did a quick search through the forum and came onto THIS (http://www.picbasic.co.uk/forum/showthread.php?t=332&highlight=HPWM+16F88). Hopefully, this thread with the datasheet will help explain it a little better.
...oops, looks like Bruce beat me to it.

George
- 1st November 2005, 21:48
Great - IT'S ALIVE!!! Thanks so much guys really appreciate the help

sougata
- 2nd November 2005, 04:50
Dear Bruce,

Thanks Bruce.

I should have gone through the datasheet before commenting.

Regards

Sougata