Electronic – PWM 1HZ PIC18F14K50

frequencypicpwm

So, I'm trying to achieve a 1HZ PWM frequency with a Duty Cycle of about 70%.
The problem that I encountered was with the minimum PWM frequency that the PIC18F14K50 can reach, which is about 1.892HZ, using PR2=255(max),FOSC equals to 31kHZ(changed from 16MHZ) and prescaler of TIMER2=16:

PWM FREQUENCY= (PR2+1)*4*TOSC*prescaler

So my question resides in a manner to achieve that 1HZ for the PWM Frequency with a Duty Cycle of 70%.

Notes: Can't use delays(function) and can't change the hardware(PIC), so the only option is via Software.

Bellow is the code used to achieve a frequency of 1.892HZ:

//Variables 
int DC; // Duty cycle
//
OSCCON=0; // 31kHZ

// Configure PWM Module 1.892 HZ
    OpenTimer2(T2_PS_1_16); // Prescaler 16 
    OpenPWM1(0xFF); //Configure PWM module and initialize 1 HZ ; PR2 =255
    SetDCPWM1(0); // set duty cyle  
    SetOutputPWM1(SINGLE_OUT, PWM_MODE_1); 

void LED(void) { 

    DC=70; // 70%

    SetDCPWM1((int) DC * 10.23); //set the duty cycle 70% in 10bits//
}

EDIT:
Trying to follow the comments of all of you I tried this with TIMER0 and now with FOSC= 16MHZ :

void highISR(void) {
    // Check if there was an overflow in TIMER0
    if (INTCONbits.TMR0IF == 1) { 
        LATCbits.LATC5=1; // LED ON 


        INTCONbits.TMR0IF = 0; 
        WriteTimer0(Ktimer); 
    }
}

#pragma code HighInterruptVector=0x0008

void HighInterruptVector(void) {
    _asm
            goto highISR
            _endasm
}
#pragma code
 // CONFIG TIMER0 
    OpenTimer0(TIMER_INT_ON & // Use interruptions
            T0_16BIT & // 16 bit timer
            T0_SOURCE_INT & // Use internal clock as source
            T0_EDGE_FALL & // Update on falling edge
            T0_PS_1_128); // 128 prescaler (lowest period possible) 
    // FOSC = 16 MHz ==> FTY = 16/4 = 4MHz ==> -------TCY = 250 ns
    // Timer 0 prescaler = 128 ==> Count on every--------- 250 ns * 128 = 32 us
    // 1 seg counting = --------1s / 32u = 31250
    //31250*0,7 =21875 70% DC

    Ktimer = 65536 - (21875);
    //WriteTimer0(Ktimer); 


// So the flag occurs 
While(1){

WriteTimer0(Ktimer)
LATCbits.LATC5=0; // LED OFF
}

But led wont turn on. 100% certain that the fault is in how the code is constructed.

Best Answer

Final answer to anyone wondering here's the code that worked for me. It's simple , because I really don't need a very specific code or precision for the work I'm doing. Wanna thank you all that commented and helped me get the right ideas.

#include <p18f14k50.h>
#include <stdlib.h>
#include <delays.h>
#include <timers.h>


int Ktimer; // variable for overflow 
int time1=10; // Period 1HZ 1*0.1 from Ktimer = 1 second 
int time2=7; // Duty Cycle
//--------------------------- End of Variables ------------------------------------
//********************************************************************************* 

void PWM_LED(void){


    if (time2 > 0)
        LATAbits.LATA5=0; // LED ON 
    else
        LATAbits.LATA5=1; // LED OFF
}
#pragma interruptlow highISR

void highISR(void) {
    // Check if there was overflow by the timer 
    if (INTCONbits.TMR0IF == 1) { 

        time1--;
        time2--;

       INTCONbits.TMR0IF = 0; // Put Flag at zero again 
       WriteTimer0(Ktimer);


    }
}

#pragma code HighInterruptVector=0x0008

void HighInterruptVector(void) {
    _asm
            goto highISR
            _endasm
}
#pragma code


//********************************************************************************* 
//-------------------------------------- Main -------------------------------------
//********************************************************************************* 
void main (void)
{

  //****************************Other congigurations********************************* 
  OSCCON=0x70;        // Select 16 MHz internal clock   

  //************************************Setups*************************************** 

    // Interrupts
    INTCONbits.GIEH = 1; // Enable all high priority interrupts (also required for LOW priority)

    INTCONbits.TMR0IF = 0; //TMR0 Overflow Interrupt Flag bit (must be cleared by software) AO rebentar activa a flag

    INTCONbits.TMR0IE = 1; //Enable TMR0 Overflow Interrupt Enable bit
    INTCON2bits.TMR0IP = 1; //Set TMR0 Overflow Interrupt Priority bit: 1 = High priority

    // Configure Timer0  0,1 seconds  
    OpenTimer0(TIMER_INT_ON & // Use interruptions
            T0_16BIT & // 16 bit timer
            T0_SOURCE_INT & // Use internal clock as source
            T0_EDGE_FALL & // Update on falling edge
            T0_PS_1_128); // 128 prescaler (lowest period possible) 
    // FOSC = 16 MHz ==> FTY = 16/4 = 4MHz ==> -------TCY = 250 ns
    // Timer 0 prescaler = 128 ==> Count on every--------- 250 ns * 128 = 32 us
    // 0.1 seg counting = --------0.1s / 32u = 3125
    // 2^16- 3125 = 62411;
    //Ktimer = 62411;  0.1 seconds
    Ktimer = 65536 - (3125);
    WriteTimer0(Ktimer); // Timer0 will overflow in 100ms


  Delay10TCYx( 5 );             // Delay for 50TCY


  //********************************************************************************* 
  //-------------------------------------- Main cycle -------------------------------
  while (1)
  {

    PWM_LED();

    if(time1 <= 0){ //reset
    time1=10; 
    time2=7; 
    }

    Delay10KTCYx(10);   

  }
  //-------------------------------------- End of Main Cycle ------------------------
  //********************************************************************************* 

  /* Close Peripherals */

  CloseTimer0();
}