So far the code for the LCD works fine alone, and the PWM code works fine alone, but when I put them together the PWM period doesn't go at what I set it. It is on a minimum on and maximum off instead of the 50:205 it should be.
Any clues
Code: Select all
void main(){
char *text;
char oldstate4 = 0;
char oldstate5 = 0;
unsigned short current_duty, old_duty;
ANSEL = 0; // Configure AN pins as digital I/O
ANSELH = 0;
//INTCON = 0;
TRISB = 0xFF; // set PORTB to be input
TRISC = 0; // set PORTD to be output
PORTC = 0x00; // initialize PORTD
Pwm_Init(100000);
current_duty = 50; // initial value for current_duty
old_duty = 0; // old_duty will keep the 'old current_duty' value
PWM_Start(); // start PWM1
Lcd_Config(&PORTC, 4, 7, 6, 3, 2, 1, 0); // Lcd_Init_EP5, see Autocomplete
LCD_Cmd(LCD_CURSOR_OFF); // send command to LCD (cursor off)
LCD_Cmd(LCD_CLEAR); // send command to LCD (clear LCD)
text = "Voltmeter"; // assign text to string
LCD_Out(1,1,text); // print string a on LCD, 1st row, 1st column
text = "Initialising.."; // assign text to string
LCD_Out(2,2,text);