Announcement

Collapse
No announcement yet.

No response from the uLCD-144(GFX), newbie

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    I post some sample of the code with a GPS, and a PIC18F26K22.

    Baudrate change on the fly, refresh rate of the NMEA sentences at 10hz and additional ZDA NMEA sentence.

    Code:
    @ ERRORLEVEL -306 
    
      #CONFIG   ;  The PBP configuration for the PIC18F26K22 is:
    ;    CONFIG FOSC     = RCIO6        ; External RC oscillator
         CONFIG FOSC     = HSHP            ; HS oscillator (high power > 16 MHz)
    
    ;*---------------------------------4x PLL ENABLE--------------------------------------*|
    ;*  4X PLL Enable                                                                     *|
    ;*    CONFIG PLLCFG  = OFF            ;Oscillator used directly                         *|
        CONFIG PLLCFG    = ON            ;Oscillator multiplied by 4                       *|
    ;*------------------------------------------------------------------------------------*|
    ;
    ;  Primary clock enable bit
    ;    CONFIG PRICLKEN = OFF            ;Primary clock can be disabled by software
        CONFIG PRICLKEN  = ON            ;Primary clock enabled
    ;
    ;  Fail-Safe Clock Monitor Enable bit
        CONFIG FCMEN     = OFF            ;Fail-Safe Clock Monitor disabled
    ;    CONFIG FCMEN    = ON            ;Fail-Safe Clock Monitor enabled
    ;
    ;  Internal/External Oscillator Switchover bit
        CONFIG IESO      = OFF            ;Oscillator Switchover mode disabled
    ;    CONFIG IESO     = ON            ;Oscillator Switchover mode enabled
        
        CONFIG  BOREN    = SBORDIS      ; Brown-out Reset enabled in hardware only (SBOREN is disabled)
        
    ;*--------------------------------------------------------------------------------------------------------;|
        CONFIG  WDTEN    = ON           ; WDT is always enabled. SWDTEN bit has no effect                     ;|
        CONFIG  WDTPS    = 32768        ; 1:32768 ---> HERE enable the watchdog timer with a 1:32768 postscale;|
    ;*--------------------------------------------------------------------------------------------------------;|
        
        CONFIG  PWRTEN   = ON
        CONFIG  HFOFST   = ON           ; HFINTOSC output and ready status are not delayed by the oscillator stable status
        CONFIG  MCLRE    = EXTMCLR      ; MCLR pin enabled, RE3 input pin disabled
        CONFIG  LVP      = OFF          ; Single-Supply ICSP disabled
        CONFIG  XINST    = OFF          ; Instruction set extension and Indexed Addressing mode disabled (Legacy mode)
        CONFIG  DEBUG    = OFF          ; Disabled
    
    ;*--------------------------------------------------------------------------------------------------------|
    ;*                                  | -------------------------- |                                        |
    ;*  -----------------------------   |  [PROTECTED OPTION FUSES]  |  ------------------------------------  |
    ;*                                  | -------------------------- |                                        |
    ;*--------------------------------------------------------------------------------------------------------|
    
        CONFIG  CP0 = OFF             ; Block 0 (000800-003FFFh) not code-protected
        CONFIG  CP1 = OFF             ; Block 1 (004000-007FFFh) not code-protected
        CONFIG  CP2 = OFF             ; Block 2 (008000-00BFFFh) not code-protected
        CONFIG  CP3 = OFF             ; Block 3 (00C000-00FFFFh) not code-protected
        CONFIG  CPB = OFF             ; Boot block (000000-0007FFh) not code-protected
        CONFIG  CPD = OFF             ; Data EEPROM not code-protected
        CONFIG  WRT0 = OFF            ; Block 0 (000800-003FFFh) not write-protected
        CONFIG  WRT1 = OFF            ; Block 1 (004000-007FFFh) not write-protected
        CONFIG  WRT2 = OFF            ; Block 2 (008000-00BFFFh) not write-protected
        CONFIG  WRT3 = OFF            ; Block 3 (00C000-00FFFFh) not write-protected
        CONFIG  WRTC = OFF            ; Configuration registers (300000-3000FFh) not write-protected
        CONFIG  WRTB = OFF            ; Boot Block (000000-0007FFh) not write-protected
        CONFIG  WRTD = OFF            ; Data EEPROM not write-protected
        CONFIG  EBTR0 = OFF           ; Block 0 (000800-003FFFh) not protected from table reads executed in other blocks
        CONFIG  EBTR1 = OFF           ; Block 1 (004000-007FFFh) not protected from table reads executed in other blocks
        CONFIG  EBTR2 = OFF           ; Block 2 (008000-00BFFFh) not protected from table reads executed in other blocks
        CONFIG  EBTR3 = OFF           ; Block 3 (00C000-00FFFFh) not protected from table reads executed in other blocks
        CONFIG  EBTRB = OFF           ; Boot Block (000000-0007FFh) not protected from table reads executed in other blocks
    
      #ENDCONFIG
    
    define  OSC 64
    
            INCLUDE "modedefs.bas"
            INCLUDE "ALLDIGITAL.pbp"         ; Make all ports Digital
            INCLUDE "DT_INTS-18.bas"        ; Base Interrupt System
            INCLUDE "ReEnterPBP-18.bas"     ; Include if using PBP interrupts
    
    OSCCON    = %01110000   ; 64Mhz
    OSCTUNE.6 = 1           ; Enable 4x PLL
    
    while ! osccon2.7 :WEND ; to make sure the pll has stabilised before you run any other code
    
    '------------------------------------------------------------------------------|
    '                            INITIALIZE RAM                                    |
    '------------------------------------------------------------------------------|
    initialize:
        CLEAR       
    '-------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    TRISA = %00000000   'use TRISA to specify which pin is (1 = input) and which (0 = output)  (ALL pins are output)
    TRISB = %10000000   'use TRISB to specify which pin is (1 = input) and which (0 = output)  (RB7 PORTB.7 is the RX input pin of the EUART, the rest are output)
    TRISC = %10000000   'use TRISC to specify which pin is (1 = input) and which (0 = output)  (RC7 PORTC.7 is the RX input pin of the EUART, the rest are output)
                        'in PORTC the RC3 attached is an LED. 
    
    '----------------------- At start all PORTS LOW -------------------------|
    PORTA = 0            'make low all ports at A range                      |
    PORTB = 0            'make low all ports at B range                      |
    PORTC = 0            'make low all ports at C range                      |
    PORTE = 0            'make low all ports at E range                      |
    
    '-------------------------- COMPARATORS OFF -----------------------------|
    CM1CON0.7 = 0 'Disable comparator1                                       |
    CM2CON0.7 = 0 'Disable comparator2                                       |
    
    '*----------------------- | EUART 1 Configuration  | --------------------------|
            
            RCSTA = $90 ' Enable serial port & continuous receive
            TXSTA = $24 ' Enable transmit, BRGH = 1
            'CLROERR = 1 ' Clear overflow automatically
            SPBRG = 160 ' 38400 Baud @ 64MHz, -0,08%
            SPBRGH = 1
            BAUDCON.3 = 1         ' Enable 16 bit baudrate generator
    
    '*----------------------- | EUART 2 Configuration  | --------------------------|
    
            RCSTA2 = $90 ' Enable serial port & continuous receive
            TXSTA2 = $24 ' Enable transmit, BRGH = 1
            'CLROERR2 1 ' Clear overflow automatically
            SPBRG2 = 130 ' 9600 Baud @ 64MHz, -0,02%
            SPBRGH2 = 6
            BAUDCON2.3 = 1         ' Enable 16 bit baudrate generator
            
    '-----------sent a sentence to gps, this is not working at the moment----------|
    ' When the GPS Module is POWERED ON, then the following sentenses are received. 
    
    '          $PMTK011,MTKGPS*08
    '          $PMTK010,001*2E
    '          $PMTK010,002*2D   
    
    pause 800 
    HSEROUT2 ["$PMTK251,38400*27",13,10]      ' 38400 boundrate, check MTK manual configuration
    pause 800
    
    SPBRG2 = 160 ' 38400 Baud @ 64MHz, -0,08%
    SPBRGH2 = 1
    Pause 500
    
    HSEROUT2 ["$PMTK314,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0*29",13,10]
    pause 100
    
    HSEROUT2 ["$PMTK220,100*2F",13,10]        ' 100(millisecond)=0.1(sec)-->1/0.1= 10Hz
    pause 100
    
    'HSEROUT2 ["$PMTK251,38400*27",%00001101,%00001010]      ' 38400 boundrate, check MTK manual configuration
    'pause 500
    'HSEROUT2 ["$PMTK220,100*2F",%00001101,%00001010]        ' 100(millisecond)=0.1(sec)-->1/0.1= 10Hz
    
    timeout     con     1000
    LED         VAR     PORTC.4
    PWRLED      var     PORTC.3 ' indicates that PIC is working on port C.4
    TOGPS       var     PORTB.5 ' this is the pin serout to GPS rx port
    
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler   TMR0_INT,  _ToggleLED,   PBP,  yes
        endm
        INT_CREATE             ; Creates the interrupt processor
    ENDASM
    T0CON = %10010110             ; T0 = 16-bit, Prescaler 8
    @   INT_ENABLE  TMR0_INT     ; enable Timer 0 interrupts
    
    ' -----------------------------------------------------------------------------|  
    '                          [ LCD Initialization ]                              |
    '------------------------------------------------------------------------------|
              ' FIRST TIME BOOTUP: We give plenty of time for tbe LCD '
    
    pause 2000  
    HSEROUT[$55]      ' uOLED Initialize this is the 'U' character of autoband rate to LCD
    Hserin  [wait(6)]
    hserout[$56,$01]  ' this is the Version info --> '01 10 17 28 28   -->> "(("
    Hserin  [wait(1),wait(16),wait(23),wait(40),wait(40)]
    HSEROUT [$45]    ' clear the LCD
    Hserin  [wait(6)]
    pause 500
    
    hserout[$73,$00,$03,$11,$ff,$ff," Leonardo Bilalis",$00] 
    Hserin  [wait(6)]           
    hserout[$73,$02,$06,$10,$ff,"     Copyright 2018",$00]
    Hserin  [wait(6)]
    pause 500
    
    Hserout[$4F,01]   'Set transparent / opaque TEXT ($00 for transparent or $01 for opaque)
    Hserin  [wait(6)]
    
    HSEROUT [$45]    ' clear the LCD
    Hserin  [wait(6)]
    
    high led
    
    Main:
        pause 10
    goto main
    
    '---[INT - interrupt handler]---------------------------------------------------
    
    ToggleLED:
         TOGGLE pwrled
    @ INT_RETURN

    Comment


    • #17
      Thank you for sharing your code, Leonardo.

      Based on our discussion in private message, you want your project to be cost-effective and you also mentioned that you’re new to programming.

      If I may suggest, I think it is much efficient for you to use an ATmega328 MCU. This MCU can also achieve your objective in using the PIC MCU (parsing NMEA messages). The advantage in using ATmega328 rather than PIC in your case is that it can be programmed using Arduino IDE. The IDE supports 4DSystems LCD libraries as well as parsing NMEA messages libraries and it has also active forum community.

      If you’re new to Arduino IDE, you may refer to this link for information https://www.arduino.cc/en/Guide/HomePage.

      Also, if you need further assistance, feel free to ask.

      Best regards,
      Vince_4D

      Comment


      • #18
        Hi Vince,

        Thanks a lot for your advise. I use the PIC because there are plenty of different choises on peripherals. And i have already ordered the first 50 pieces of PIC18F46K22 TQFP for my project. The Cost didnt exceed 130 euros.

        Apart from that i dont mind so much for the ready libraries as those wont improve any of my knowledge and will not help me to Learn.

        I have manage to parse the Data and i only need to send the INFO on the display. That is what matters to me.

        Now i need to Learn more about programming in order to reach the target for the project.

        Thanks Once again for your Kind help.

        Comment


        • #19
          I see.

          You might want to check this video clip for reference, https://www.youtube.com/watch?v=x_YEq65xmJw.
          In this project, the customer was able to utilize a uOLED-160G2 which has a Goldelox chip, same with uLCD-144, in parsing the NMEA messages. The display was configured as a stand-alone device having a GFX PmmC. So basically, you could implement the NMEA parsing with the use of LCD alone.

          Hope this will help.

          Best regards,
          Vince_4D

          Comment


          • #20
            Originally posted by Vince_4D View Post
            I see.

            You might want to check this video clip for reference, https://www.youtube.com/watch?v=x_YEq65xmJw.
            In this project, the customer was able to utilize a uOLED-160G2 which has a Goldelox chip, same with uLCD-144, in parsing the NMEA messages. The display was configured as a stand-alone device having a GFX PmmC. So basically, you could implement the NMEA parsing with the use of LCD alone.

            Hope this will help.

            Best regards,
            I know but for me would be quite difficult to start from the beginning and learn a new language to program the on board GOLDELOX chip.

            I would love to, but it will take long time.

            Comment


            • #21
              This is a working code for those who like to use a PIC micro controller, externally.

              GPS speedometer with time and Date. Code can be configured for each country simply change the difference from GMT.
              Attached Files

              Comment

              Working...
              X