Help with 16f688


Closed Thread
Results 1 to 8 of 8
  1. #1
    jessey's Avatar
    jessey Guest

    Default Help with 16f688

    Hello,

    This if my first time using the 16f688 micro and I am having trouble getting it set up properly to print to my Lcd in a 4 bit mode. I looked in the archives and couldn't find anything that deals with Lcd's using the 16f688. I tried to use CMCON0 = 7 to shut off the comparators but when I compile I get an error saying syntax error?

    The Lcd does turn on but the top line is just all dark black blocks with light gray blocks on the bottom line. The Led flashes properly in the Mainloop. Can anyone here help me understand what I'm doing wrong for the Lcd. Any suggestions would be greatly appreciated.

    Thanks
    jessey

    Code:
    '*******************************************************************************
    '* Name     : Blink Led                                                        *
    '* Author   : Jessey Montgomery                                                *
    '* Includes :                                                                  *
    '* Date     : November 15/th 2006                                              *
    '* Version  : PicBasic Pro Ver 2.45, MPASM Ver 03.60, Using MicroCode Studio   *
    '*          : 2.1.0.7, EPIC Version 2.46 beta programmer, PIC16F688-I/P 04470AY*
    '*******************************************************************************
    
    '                               --------------
    '                               |   16f688   |
    '                   VDD+ (--->) |1         14| (<---) VSS-
    '                               |            |
    '   RA5/TICKI/OSC1/CLKIN (<-->) |2         13| (<-->) RA0/AN0/C1IN+/ICSPDAT/ULPWU 
    '                               |            |
    'RA4/AN3/TIG/OSC2/CLKOUT (<-->) |3         12| (<-->) RA1/AN1/C1IN-/Vref/ICSPCLK 
    '                               |            |
    '            RA3/MCLR/Vpp(--->) |4         11| (<-->) RA2/AN2/TOCKI/INT/C1OUT
    '                               |            |
    '              RC5/RX/DX (<-->) |5         10| (<-->) RC0/AN4/C2IN+
    '                               |            |
    '        RC4/C2OUT/TX/CX (<-->) |6          9| (<-->) RC1/AN5/C2IN-
    '                               |            |
    '                RC3/AN7 (<-->) |7          8| (<-->) RC2/AN6
    '                               |            |
    '                               --------------
    
    '------------------------------------------------------------------------------'
    '------------- Clear Each Port Before Setting The TRIS Registers --------------'
    '------------------------------------------------------------------------------'
                                    
          Clear   ' Set all ram registers to zero
          PORTA = 0
          PORTC = 0                           
    
    '--------------------------- VSS VDD MCLR Ect. Pins ---------------------------'
     
    '     VDD +       '(pin 1)
    '     VSS -       '(pin 14)
     
    '------------------- SET THE TRIS  ------------------'               
     
    '-------------------- PORTA PINS --------------------' 
                                    
          TRISC.0 = 0 '(pin 10) ...Blue.................Lcd Data bit 4   
          TRISC.1 = 0 '(pin 9) ....White................Lcd Data bit 5 
          TRISC.2 = 0 '(pin 8) ....Green................Lcd Data bit 6              
          TRISC.3 = 0 '(pin 7)  ...Orange...............Lcd Data bit 7  
          TRISC.4 = 0 '(pin 6)  ...Orange/Black.........Lcd Register select     
          TRISC.5 = 0 '(pin 5)  ...Blue/White...........Lcd Enable bit      
    
    '-------------------- PORTC PINS --------------------'
                                 
          TRISA.0 = 1 '(pin 13) NOT USED  
          TRISA.1 = 0 '(pin 12) NOT USED  
          TRISA.2 = 1 '(pin 11) NOT USED   
          TRISA.3 = 1 '(pin 4)  NOT USED   
          TRISA.4 = 1 '(pin 3)  NOT USED 
          TRISA.5 = 1 '(pin 2)  .......................Led 
    
    ;==============================================
    ;
    ;       Configuration Bits
    ;
    ;==============================================
    
    '  _FCMEN_ON                    EQU     H'3FFF'
    '  _FCMEN_OFF                   EQU     H'37FF'
    '  _IESO_ON                     EQU     H'3FFF'
    '  _IESO_OFF                    EQU     H'3BFF'
    '  _BOD_ON                      EQU     H'3FFF'
    '  _BOD_NSLEEP                  EQU     H'3EFF'
    '  _BOD_SBODEN                  EQU     H'3DFF'
    '  _BOD_OFF                     EQU     H'3CFF'
    '  _CPD_ON                      EQU     H'3F7F'
    '  _CPD_OFF                     EQU     H'3FFF'
    '  _CP_ON                       EQU     H'3FBF'
    '  _CP_OFF                      EQU     H'3FFF'
    '  _MCLRE_ON                    EQU     H'3FFF'
    '  _MCLRE_OFF                   EQU     H'3FDF'
    '  _PWRTE_OFF                   EQU     H'3FFF'
    '  _PWRTE_ON                    EQU     H'3FEF'
    '  _WDT_ON                      EQU     H'3FFF'
    '  _WDT_OFF                     EQU     H'3FF7'
    '  _LP_OSC                      EQU     H'3FF8'
    '  _XT_OSC                      EQU     H'3FF9'
    '  _HS_OSC                      EQU     H'3FFA'
    '  _EC_OSC                      EQU     H'3FFB'
    '  _INTRC_OSC_NOCLKOUT          EQU     H'3FFC'
    '  _INTRC_OSC_CLKOUT            EQU     H'3FFD'
    '  _EXTRC_OSC_NOCLKOUT          EQU     H'3FFE'
    '  _EXTRC_OSC_CLKOUT            EQU     H'3FFF'
    '  _INTOSCIO                    EQU     H'3FFC'
    '  _INTOSC                      EQU     H'3FFD'
    '  _EXTRCIO                     EQU     H'3FFE'
    '  _EXTRC                       EQU     H'3FFF' 
    
    @ __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _CP_OFF 
    
    '------------------------------------------------------------------------------'
    '------------------------ Connections For Parallel Lcd ------------------------'
    '-------------------------- To 16F688 Microprocessor --------------------------'
    '--------------------------------- 4 Bit Mode ---------------------------------'
    '------------------------------------------------------------------------------'
    ' LCD    Wire                                                 
    'Pin No. Color             Symbol  Function               Connections To 16F688 
    '------  ------            ------  --------               ---------------------
    ' 1      Black              Vss    Ground ---------------Connect to -5V  
    ' 2      Red                Vdd    +5V ------------------Connect to +5V   
    ' 3      White / Black      Vo     LCD contrast 10K pot -Connect to center pad
    '                                                       -other 2 pads to + & -
    ' 4      Orange / Black     RS     Register select ------Connect to pin  (6) RC4 
    ' 5      Red / White        R/W    Read / write ---------Connect to -5V 
    ' 6      Blue / White       E      Enable ---------------Connect to pin  (5) RC5  
    ' 7     (not used)          DB0    Data bit 0                                  
    ' 8     (not used)          DB1    Data bit 1                                   
    ' 9     (not used)          DB2    Data bit 2                                     
    ' 10    (not used)          DB3    Data bit 3                                    
    ' 11     Blue               DB4    Data bit 4 -----------Connect to pin (10) RC0 
    ' 12     White              DB5    Data bit 5 -----------Connect to pin  (9) RC1 
    ' 13     Green              DB6    Data bit 6 -----------Connect to pin  (8) RC2
    ' 14     Orange             DB7    Data bit 7 -----------Connect to pin  (7) RC3 
    
    DEFINE LCD_EREG PORTC                   'Set LCD Enable port
    DEFINE LCD_EBIT 7                       'Set LCD Enable bit  
    
    ANSEL = %00000000  ' no analog inputs
    
    Led VAR PORTA.5 ' (pin 2)
    
    '----------------------- Set Initial Time Variables -------------------------
    
    PAUSE 2000 'wait for the Lcd to stabilize, show version screen below  
              lcdout $fe,1,"     Blink      "
            lcdout $fe,$c0,"      Led       "
            pause 1000               
    
       GOTO Mainloop 
    
    Mainloop
    
         HIGH Led
           Pause 500
         Low Led
           Pause 500
    
    goto Mainloop

  2. #2
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    jessey, Try adjusting the voltage on the Contrast pin of the LCD. It should be close to 0 volts..

    Dave Purola,
    N8NTA

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    There's few missing DEFINE and one bad to fit your actual hardware.
    Code:
    DEFINE LCD_RSREG PORTC 'LCD register select port 
    DEFINE LCD_RSBIT 4 'LCD register select bit 
        ' 4      Orange / Black     RS     Register select ------Connect to pin  (6) RC4 
    
    DEFINE LCD_EREG PORTC 'LCD enable port 
    DEFINE LCD_EBIT 5 'LCD enable bit 
        ' 6      Blue / White       E      Enable ---------------Connect to pin  (5) RC5  
    
    
    DEFINE LCD_DREG PORTC 'LCD data port 
    DEFINE LCD_DBIT 0 'LCD data starting bit 0 or 4 
        ' 11     Blue               DB4    Data bit 4 -----------Connect to pin (10)     RC0 
        ' 12     White              DB5    Data bit 5 -----------Connect to pin  (9) RC1 
        ' 13     Green              DB6    Data bit 6 -----------Connect to pin  (8) RC2
        ' 14     Orange             DB7    Data bit 7 -----------Connect to pin  (7) RC3
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    jessey's Avatar
    jessey Guest


    Did you find this post helpful? Yes | No

    Default Working good now

    Hi Steve,

    Thanks for the define codes, my Lcd works like a charm now. I'll remember that the next time I change a Lcd Define to another port.

    Thanks again
    jessey

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Thumbs up

    You're welcome.

    You live in a great city so far. i went there few years ago.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  6. #6
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Me too live in a great city Steve.
    I have not seen you here yet.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    A contract and/or a pre-paid airplane ticket always help
    Last edited by mister_e; - 20th October 2006 at 23:24.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  8. #8
    jessey's Avatar
    jessey Guest


    Did you find this post helpful? Yes | No

    Default

    Hi Steve,

    I spent some time in Montreal too, in the late 1960's and early 1970's. Beautiful city that still holds fond memories for me.

    It's a small world.

    jessey

Similar Threads

  1. DS1820 with 16f688
    By jessey in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 23rd May 2009, 06:07
  2. 16f688 <-> Max232
    By PlantBob in forum Serial
    Replies: 1
    Last Post: - 25th March 2008, 15:57
  3. Error programming 16F688
    By manxman in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 23rd July 2007, 22:10
  4. Direct replacement for 16F688
    By Christopher4187 in forum General
    Replies: 10
    Last Post: - 7th September 2006, 02:20
  5. Problem with 16F688 and Hserout
    By DWV in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 19th March 2005, 06:37

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts