PDA

View Full Version : 16F88 - CCPMX strange fuse setting for HWPM



flotulopex
- 5th April 2007, 21:33
Hello,

I can be wrong, but I think there could be a mistake in my PIC16F88's data-sheet.

To activate the PWM function on RB0, according to the data-sheet, I need (at least I assume it is so) to set CCPMX_ON.

Doing so, it will activate PORTB.3!!!

This is what I can read in the data-sheet:
<img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=1521&stc=1&d=1175804943">

This is what I have to do to make it work on RB0:
<img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=1522&stc=1&d=1175805152">

Question: am I missunderstanding something or is this an error in the documentation?

Darrel Taylor
- 5th April 2007, 21:59
You would think that "ON" means a 1 in that bit position.
But not in this case.

If you look in the M16f88.inc file in the INC folder under PBP, you'll see these two lines for the CCPMX config bit.

CCPMX_ON equ 2FFF0000h ; X0 XXXX XXXX XXXX
CCPMX_OFF equ 2FFF1000h ; X1 XXXX XXXX XXXX


There you can see that 1 is OFF, and 0 is ON.

Therefore CCPMX_OFF = RB0, and CCPMX_ON = RB3.

Added: The default is 1, so you shouldn't need to do anything to have the CCP on RB0.
But you will need to set the CCP DEFINES, since PBP's default is PORTB.3 for the HPWM command on a 18F88.

DEFINE CCP1_REG PORTB
DEFINE CCP1_BIT 0

HTH,

flotulopex
- 5th April 2007, 22:20
Thanks Darrel,

I thought the data-sheets where already the most difficult documents to understand... In fact, it's the whole PIC logic ;)

How would anyone think that "1" doesn't mean "ON"? One can just not verify every and each bit setting any time he uses it, no?

BTW, I don't set any DEFINE and it works perfectly... on RB0 when the fuse is set to "OFF".

NB: just wondering how many PIC-freaks do know what you just explained...

Darrel Taylor
- 5th April 2007, 22:25
More than likely, you have manualy set the TRIS registers so that RB0 is an OUTPUT.

That's the only thing that the DEFINE's will affect.

Normally, the HPWM command will set the pin to OUTPUT on it's own, but in that case it needs the proper defines.

"PIC-freaks", you calling me a Freak?
Dang I hate when people know what I really am. :D
<br>

skimask
- 5th April 2007, 22:27
Thanks Darrel,

I thought the data-sheets where already the most difficult documents to understand... In fact, it's the whole PIC logic ;)

How would anyone think that "1" doesn't mean "ON"? One can just not verify every and each bit setting any time he uses it, no?

BTW, I don't set any DEFINE and it works perfectly... on RB0 when the fuse is set to "OFF".

NB: just wondering how many PIC-freaks do know what you just explained...

Actually, there's a lot of place where a '0' means on. Look at MCLR*. You are only doing a 'Master Clear' when the pin is at logic 0, or OFF. A lot of control signals are negative logic. On a static ram chip for instance, RD*, WR*, CS*, etc.etc. In this respect, the PIC is not as isolated a case as you might think. It's been this way for a long time. I remember when I was starting out in electronics, the whole negative logic thing was one of the more difficult things to grasp, or should I say 'accept'. But there it is...and there they'll stay...

Darrel Taylor
- 5th April 2007, 22:33
Oh shoot, here's a big problem I forgot about.

If you don't set the DEFINE's, when you use the HPWM command, it will set RB3 to OUTPUT since it's the default.

If you have something providing a signal as an INPUT to RB3, it can cause a short and really screw things up.
<br>