Hi,
Still working on my aquarium lighting controller as I've discovered an issue with using the hardware PWM on the 18F4520. I've opted to use Darrels multi-SWPM files, and after a littler re-write the code compiles and runs, but with some strange quirkyness that I can't seem to get my head round.
As I already have PCB's made I need to keep the two PWM pins on port C1 and C2. Now when I use these, the RTC clock displays a stupid time of 48:85 and everything locks up as the clock is not out putting the correct time. If I change the multi-spwm pins to port D1 and D2, the clock runs fine with the correct time. Here is the settings I've used for Darrels include file
I've obviously commented out the port settings for the hardware PWM register
I basically need to configure portC so that C0, C1 and C2 are digital, C3 and C4 are used for the RTC (SDA and SCL), but I'm struggling
Still working on my aquarium lighting controller as I've discovered an issue with using the hardware PWM on the 18F4520. I've opted to use Darrels multi-SWPM files, and after a littler re-write the code compiles and runs, but with some strange quirkyness that I can't seem to get my head round.
As I already have PCB's made I need to keep the two PWM pins on port C1 and C2. Now when I use these, the RTC clock displays a stupid time of 48:85 and everything locks up as the clock is not out putting the correct time. If I change the multi-spwm pins to port D1 and D2, the clock runs fine with the correct time. Here is the settings I've used for Darrels include file
Code:
define SPWMFREQ 100 ' PWM frequency in Hz
SPWM1PIN VAR PORTC.1 ' SPWM channel 1
define SPWM1VAR _B_PWM
SPWM2PIN VAR PORTC.2 ' SPWM channel 2
define SPWM2VAR _W_PWM
Code:
'*******************************************************************************
'Port and Register settings
'*******************************************************************************
'CCP1CON = %00001100 'Set CCP1 to PWM
'CCP2CON = %00001100 'Set CCP2 to PWM
TRISA = %11101111
TRISB = %00000011
TRISD = %00000011
T0CON = %11000111