LCD_Init for multiple ports

General discussion on mikroC.
Post Reply
Author
Message
roro36
Posts: 9
Joined: 21 Sep 2010 08:10

LCD_Init for multiple ports

#1 Post by roro36 » 09 Nov 2010 12:13

I am using the PIC18F690 which has 20pins, 6 for port A, 8 for port c and 4 for port B. I need the 7 pins to run a LCD screen, 1 pin for a PWM output and 2 ADC inputs.

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);

roro36
Posts: 9
Joined: 21 Sep 2010 08:10

Re: LCD_Init for multiple ports

#2 Post by roro36 » 09 Nov 2010 12:14

PWM is on Portc5 which is not used by the LCD.

Post Reply

Return to “mikroC General”