PDA

View Full Version : HPWM statement problems with 18F45K20



CuriousOne
- 5th May 2014, 15:33
According to datasheet, 18F45K20 has up to 5 CCP/PWM modules, which itself have 4 PWM ports and can be configured independently.

However, Picbasic pro has problem with them - none of them works, and in code like below, you can write ANY port number - no errors will be given.



hpwm 1,100,1000
hpwm 2,100,1000
hpwm 3,100,1000
hpwm 99,100,1000


What is the problem?

mpgmike
- 5th May 2014, 21:02
In your defines you have to state what pin PWM 1 is (as well as 2, 3, 99, etc.; page 148 of the Manual). It looks like this:

DEFINE CCP1_REG PORTC
DEFINE CCP1_BIT 2
DEFINE CCP2_REG PORTC
DEFINE CCP2_BIT 1

Hope this helps.

CuriousOne
- 6th May 2014, 05:11
I meant a slightly different thing.

Say I have 16F870. No specific DEFINE's added.

Since this chip has 1 hpwm channel only, hpwm 1,100,1000 works. But if I type hpwm 4,100,1000, compiler will give error, since there's no such hardware port. In case of 18F45K20, compiler absolutely does not cares, what port address you enter in hpwm statement. This is the problem.

Demon
- 7th May 2014, 01:45
Does 16F870 have PWM enabled by default?

What about 18F45K20?

I make it a habit not to assume and set feature registers as required.

Robert

CuriousOne
- 8th May 2014, 04:41
According to manual, HPWM statement does all required configs by itself.

Here not problem in HPWM not working, here problem is compiler passing any garbage to hpwm statement without error.