Pic16f690 & lcd

Discussion in 'Embedded Systems and Microcontrollers' started by davidho3, Aug 19, 2010.

  1. davidho3

    Thread Starter New Member

    Aug 19, 2010
    1
    0
    I am using 16F690 and try to write a string to 16x2 LCD. (16F690 PORTC , c0-c3 data bit, c4 RS and c5 enable) However, the software didn't work to run LCD. So, I changed it to a simple test code to test PORTC enable/disable. I have a LED conneted to C7 bit. The program can run successful by MikroPro. but, no luck on Hi-TECH C (verision 9.65)

    Your feedback are highly appreciated

    #include <htc.h>
    #include "stdio.h"
    #include <string.h>
    __CONFIG(MCLRDIS & UNPROTECT & WDTDIS & PWRTDIS & XT );

    void main(void)
    {
    PORTC = 0;
    TRISA = 0xff; // PORT A input, Bit 2 AN2 input
    TRISB = 0xc0; // Port B , RB7 & RB6 are input
    TRISC = 0x40; // all PORTC output
    ANSEL = 4; // Read AN2
    ANSELH = 0;
    CM1CON0 = 0;
    CM2CON0 = 0;

    C1ON=0; // Turn off Comparators
    C2ON=0;
    DelayMs1(100);

    // I'm expecting LED (C7) blinking.
    do {
    PORTC =0;
    DelayMs1(100);
    PORTC= 0xff;
    DelayMs1(100);
    } while (1);
    }
     
  2. cheezewizz

    Active Member

    Apr 16, 2009
    82
    10
    Where's your DelayMs1() function actually declared? Does this compile? I woulda thought it might complain about that, just include delay.c and delay.h into your project and use DelayMs(unsigned char) instead... And as you're not using the ADC (or are you?) I wouldn't bother with the ANSEL/ANSELH bits. Not that that would make much difference I wouldn't have thought, maybe someone else could clear that up. And while we're at it, wouldn't portC all as output be TRISC = 0x00?
     
Loading...