Never mind...
Never mind...
Last edited by mtripoli; - 20th April 2011 at 22:11.
Well, for all my quick 'n dirty the workaround reverts my pin9 (PortC.1) ADC back to how it should be...
....the actual HPWM command itself is still playing havoc with the signal....when I feed a steady sine wave into the ADC pin, it getting chopped up as viewed on a scope, as when the HPWM 2 command runs it interferes with PortC.1 - my now (naive) thinking is that it's forcing the pin to be an output, which then drags my sine wave analogue input signal down to zero, then my 'kludgey' follow on command makes the pin an input again...which restores the signal. But you can imagine the end result, it's as if a switch is being flicked rapidly thereby shunting the signal to ground .....fugly.Code:HPWM 2, duty, 32767 TRISC.1 =1 'Remake PIN 9 PortC.1 an input again following HPWM command
i'm exhausted on this one & don't have an immediate good solution...I need to sleep on it (still a high possibility I'm just doing something wrong as my head is fuzzy now!). Tomorrow, I may sit down & work out how do do HPWM longhand using the PICs registers (one whole days lost on something as simple as this....eek!)
Last edited by HankMcSpank; - 20th April 2011 at 23:31.
DEFINE CCP2_REG PORTC
DEFINE CCP2_BIT 3
Should take care of it. PBP defaults to PORTC.1 for CCP2 if you don't tell it otherwise.
Thanks Bruce ...that did it....you've just made an impossibly bad day...just bad now
Like I say it's my first time using the 2nd HPWM channel ....but also my first time using this newish PIC in anger - thought i was going crazy.
PWM, SHmeeWM.....
These new 16F18xx chips are small in the eye but really beasts!
I had my difficult time in setting them too, but nowI really like them.
Here is my setup for the 1827 which may help others to take into accoun the registers and not forget any of them.
Of course this is my setup and other need to make their own. It just as an example.
HTH,Code:TRISB = %11000101 TRISA = %11111100 ADCON0 = %00000001 ADCON1 = %11110011 ANSELA = %00011100 ' all digital. A/D disabled ANSELB = %01000000 APFCON0 = %00100000 APFCON1 = %00000001 BAUDCON = %00011000 CCP1CON = %00111100 'Control of CCPx modules CCP2CON = %00000000 CCP3CON = %00000000 CCP4CON = %00000000 CM1CON0.7=0 CM2CON0.7=0 CPSCON0 = 0 CPSCON1 = 0 DACCON0 = 0 FVRCON = %10000011 INTCON = %11000000 ' global & peripheral ints enabled OPTION_REG = %10000111 'Tmr0 from 256 presc and Int Clock PIR1 = 0 ' clear TMR1 int flag PIE1 = %00000001 ' TMR1 int enabled T1CON = %00110000 ' TMR1 1:8 prescale, timer1 on WPUB=%11000000 'hpwm 1,0,2000 DEFINE CCP1_REG PORTB DEFINE CCP1_BIT 3 ccptmrs=0 pr2=249 ccp1con=$0C
Ioannis
I concur...the 16F182x are a great range of chips...absolutely chocka with features.
I can't say I've had a lot of setup problems with them (certainly nothing that wasn't obvious when I complied)....other than this pesky HPWM 2 issue, the one other issue I had Darrel kindly helped sort....
I needed to modify the 16F1824.INC file (mods in red)....
The first two mods (semi colons) are standard fayre, but that last one would have taken me a good few years to get to the bottom of on my own.Code:;**************************************************************** ;* 16F1824.INC * ;* * ;* By : Leonard Zerman, Jeff Schmoyer * ;* Notice : Copyright (c) 2010 microEngineering Labs, Inc. * ;* All Rights Reserved * ;* Date : 09/14/10 * ;* Version : 2.60b * ;* Notes : * ;**************************************************************** NOLIST ifdef PM_USED LIST "Error: PM does not support this device. Use MPASM." NOLIST else LIST LIST p = 16F1824, r = dec, w = -302 INCLUDE "P16F1824.INC" ; MPASM Header ;__config _CONFIG1, _FOSC_HS ;__config _CONFIG2, _PLLEN_OFF & _LVP_OFF NOLIST endif LIST BLOCK_SIZE EQU 32 CCPTMRS0 = CCPTMRS
Last edited by HankMcSpank; - 21st April 2011 at 11:30.
What version of MPLAB do you have?
On my 8.56 and in 1827.inc file of the MPLAB Suite there are two lines (BANK5 grroup):
But on 1824.inc there is only one:Code:CCPTMRS EQU H'029E' CCPTMRS0 EQU H'029E'
So it may have to do with the update of MPLAB. Anyone with newer version?Code:CCPTMRS EQU H'029E'
Ioannis
Bookmarks