PDA

View Full Version : Macro Error



shawn
- 22nd December 2005, 02:57
Hi
I tried to use HPWM command and this error came up.

error:macro HPWM?tcc not found im macro file.

Do I have a corrupt file or what I'm using a 18F458. I've never had problems with any other commands before here is my code.

Define OSC 20 'OSC (20Mhz)
Include "modedefs.bas" 'Includes Definitions.
INTCON = %00000000 'Turns off all Interrupts.
ADCON0.0 = 1 'Turns off A/D Module
ADCON1 = 6 'Turns PortA and PortE to Digital Pins
'Defines wait time for PulsIn.
TrisB.1 = 0
Define Loader_USED 1

HPWM PortD.7,127,5600
Main:
PortB.1 = 1
Pause 1000
PortB.1 = 0
Pause 1000
Goto Main

Am I missing a define or an include. I thought maybe I got a virus or something that screwed of a file so I reloaded PBP 2.44 and had the same problem.

please help
thanks

Darrel Taylor
- 22nd December 2005, 05:23
Hi Shawn,

Oh, if only you could do that, it would make things so much easier.

But you can't assign the PIN for the HPWM command. The CCP module is hard wired to pin 17 (RC2) on the 458. So you need to supply the channel number, which in this case is 1.

HPWM 1,127,5600

And, since you're turning off all the A/D inputs, don't forget about the comparators on PORTD

CMCON = 7

<br>

shawn
- 23rd December 2005, 01:29
Hi Darrel
The reason I used PortD.7 was because the data sheet said the pic18F458 has five PWM pins and Portd.7 is one of them.

So anyway what does the one stand for in HPWM 1,127,5600. I assumed it stood for a pin but I put an 8 in place of the one and the file still assembled in microcode studios.

What im doing with this is I need to PWM channels running at the same time.
I'm running 2 PWM motors from a kit I got. HPWM command I hope will work since the frequenct will stay the same but not the duty cyle. What else can I do.
Thanks

Darrel Taylor
- 23rd December 2005, 03:23
The 18F458 only has 2 CCP modules. One is a normal CCP, and the other is an Enhanced CCP or ECCP.

The ECCP does have several outputs, and can be used for controling other types of motors, but it won't give you that many PWM outputs, and you can't choose which pin to use.

You can still use it like a normal CCP, but the output will be on RD4.

HPWM 2,127,5600

So, 1 selects the CCP and 2 selects the ECCP.
<br>

Darrel Taylor
- 23rd December 2005, 04:48
Oh yeah, forgot to mention that you need to add these lines to the bottom of the 18F458.INC file in your PBP folder.
CCPR2H = ECCPR1H
CCPR2L = ECCPR1L
CCP2CON = ECCP1CON

shawn
- 5th January 2006, 03:52
Darrel
ThankYou for your help it has been awhile since I've been able to work on my projects.
Shawn

shawn
- 5th January 2006, 05:05
Hey Darrel
I Still can not get the ECCP Port to work. I added the three lines to the INC file.
This is what I have for Code.

Define OSC 20 'OSC (20Mhz)
Include "modedefs.bas" 'Includes Definitions.
Define Loader_USED 1
INTCON = %00000000 'Turns off all Interrupts.
ADCON0.0 = 1 'Turns off A/D Module
ADCON1 = 6 'Turns PortA and PortE to Digital Pins
'Defines wait time for PulsIn.
TrisB.1 = 0
CMCON = 7
HPWM 1,127,40000
HPWM 2,200,40000
Main:
PortB.1 = 1
Pause 1000
PortB.1 = 0
Pause 1000
Goto Main

I can get this part of the code to work HPWM 1,127,40000.
But I can not get this part to work HPWM 2,200,40000.
I have all of the RD4 for ECCP and RC2 for CCP.
Please tell me what I'M missing can both ECCP and CCP run at the same time?
This is driving me nuts.
Thanks

Darrel Taylor
- 5th January 2006, 16:58
Shawn,

Oops, 1 more thing.


DEFINE CCP2_REG PORTD 'Hpwm 2 pin port
DEFINE CCP2_BIT 4 'Hpwm 2 pin bit

That let's the compiler know which pin to set as an output for HPWM. It defaults to PORTC.1
<br>