GPS Project: PIC18F26K22 or PIC18F46K22


Closed Thread
Results 1 to 40 of 69

Hybrid View

  1. #1
    Join Date
    Oct 2010
    Posts
    411

    Talking GPS Project: PIC18F26K22 or PIC18F46K22

    Dear all, i open a separate thread from this one http://www.picbasic.co.uk/forum/show...t=19080&page=2 as far as i made a mistake continuing in there. I need to apologize for that.

    I have opened it under PBP3, because a friend has a PBP3 in his laptop, i still have an older version but i'm planning to purchase the PBP3 soon.

    If an admin would like to move all the post from #66 and then, please do so in here. thanks a lot.

    Now as long as the PIC16F88, is limited to what i need to do for the project i have placed an order for the following PICs.

    1. PIC18F26K22
    2. PIC18F46K22

    I know that it will be difficult to understand the fuses but i would like to read and learn if you also help me. As i have told in the past im not a programmer so the code i have done up to now with your help it may reached my limits. I keep reading on the internet useful info and datasheets.

    So lets start from the beginning:

    I need to write a code that is getting the NMEA information from the GPS and display them at an LCD. For the LCD i prefer in the beginning to have the uLCD 1'44 from 4D Systems as fas as it doesnt need any driver. At the end of the project i would like to use the .inc files in order to use a Nokia 3310 or any other cheaper display.

    I have in mind to start from the scratch, and with your advice based on what i need to do, to write the code in an appropriate format. Please be patience as i need time to understand things. And i need to understand what am i doing on the code. It will be useful for a newbie like me in the future to read the thread and really understand. Because for you all, that are experienced and you are in a good level of programming, you do not have either time to explain what you are doing and why you are doing at a difficult parts of code.

    So now i will start the project from the very basic, like why do we pick this particular PIC, why we select these fuses.....

    I place myself under a newbie and for the rest like me, i will start with a very basic info and code. We will continue that in order to reach a good level and to complete an average project.

    At the end it will be like a training with examples but real life examples with explanations and detailed info for each step.

    If there is anyone would like to help here please do so.

  2. #2
    Join Date
    Oct 2010
    Posts
    411


    Did you find this post helpful? Yes | No

    Default Re: GPS Project: PIC18F26K22 or PIC18F46K22

    So simply i start, with what the first target is, for the code.

    1. We need to get NMEA information from any GPS module that Outputs: NMEA 0183, 9600 baud default, and display them on:

    a. A display that accept directly commands without any driver. (i have for testing the uLCD 1'44 from 4D systems with SGC ios for serial interface)
    b. A display that accept commands but we need to include the driver files. (a Nokia 3310 for example)

    Those files i believe are already completed by the experienced users in the forum.
    So they could help us and explain to us how to use them if they have the time and patience.

    The PIC that i will use for all way to the end, even for the very basic code in the beginning is the PIC18F26K22.

  3. #3
    Join Date
    Oct 2010
    Posts
    411


    Did you find this post helpful? Yes | No

    Default Re: GPS Project: PIC18F26K22 or PIC18F46K22

    First Question is: How do we select the PIC, and why did we select this particular one (PIC18F26K22) for a number of examples in this project.

    The Datasheet is very important to have it as a reference all the time.

    I will answer as a newbie and hopefully the experienced programmers and users will help to correct me or add useful additional information.

    In most of the new basic projects, we need to add components in our circuit that require more ports to be in use, specific features, High CPU SPEED and SPACE in RAM....... For example, in this final project, we will use a variety of components like:

    1. Display
    2. GPS Module, (GSM 2G-SIM module, this will be added at the end)
    3. SD card

    Each of the components required to have a dedicated port on the PIC and a specific protocol to communicate with.

    For example we need to identifyfor each component, how it works and what communication protocol needs to be connected with the PIC!!!

    A Display and the SD that has the SPI or I2C option to communicate , needs to be connected with a PIC that features these peripherals.
    Attached Images Attached Images   
    Last edited by astanapane; - 24th June 2018 at 12:22.

  4. #4
    Join Date
    Oct 2010
    Posts
    411


    Did you find this post helpful? Yes | No

    Default Re: GPS Project: PIC18F26K22 or PIC18F46K22

    Second Question is: How to do we set the configuration fuses for the PIC, especially for the PIC18F26K22?

    Right now the first step is to Flash an LED at port RC3 ( pin14 ) of the PIC18F26K22.

    The following code is written in order to Flash the LED on the specific port.

    For me at the moment is quit difficult to explain the configuration fuses for all the setups, mostly important to the ones setting the frequency at high external speed HS of 64Mhz.

    From the manual it says that we need to enable the PLL bit and also specify that we are going to use the external OSC.

    I might need the help of the ones are most expirienced to help me out regarding the setting for 64 MHZ with an external crystal 16Mhz.

    Code:
    @ ERRORLEVEL -306 ; this command prevents the compiler to give you a notice of   *
                      ; crossing page boundary - make sure bits are set              *
    '********************************************************************************* 
     
      #CONFIG   ;  The PBP default configuration for the PIC18F26K22 is:
    ;    CONFIG FOSC = RCIO6	          ; External RC oscillator
        CONFIG FOSC = HSHP	          ; HS oscillator (high power > 16 MHz)
    ;    CONFIG  FOSC = INTIO67       ; Internal oscillator block
    ;    CONFIG  PLLCFG = ON          ; Oscillator used directly
        CONFIG  PRICLKEN = ON         ; Primary clock can be disabled by software
        CONFIG  FCMEN = OFF           ; Fail-Safe Clock Monitor disabled
        CONFIG  IESO = OFF            ; Oscillator Switchover mode disabled
        CONFIG  PWRTEN = OFF          ; Power up timer disabled
        CONFIG  BOREN = SBORDIS       ; Brown-out Reset enabled in hardware only (SBOREN is disabled)
    ;    CONFIG  BORV = 190           ; VBOR set to 1.90 V nominal
        
    ;*--------------------------------------------------------------------------------------------------------;|
        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  CCP2MX = PORTC1      ; CCP2 input/output is multiplexed with RC1
    ;     CONFIG  PBADEN = OFF         ; PORTB<5:0> pins are configured as digital I/O on Reset
    ;     CONFIG  CCP3MX = PORTB5      ; P3A/CCP3 input/output is multiplexed with RB5
        CONFIG  HFOFST = ON           ; HFINTOSC output and ready status are not delayed by the oscillator stable status
    ;    CONFIG  T3CMX = PORTC0       ; T3CKI is on RC0
    ;    CONFIG  P2BMX = PORTB5       ; P2B is on RB5
        CONFIG  MCLRE = EXTMCLR       ; MCLR pin enabled, RE3 input pin disabled
    ;    CONFIG  STVREN = ON          ; Stack full/underflow will cause Reset
        CONFIG  LVP = OFF             ; Single-Supply ICSP disabled
        CONFIG  XINST = OFF           ; Instruction set extension and Indexed Addressing mode disabled (Legacy mode)
        CONFIG  DEBUG = OFF           ; Disabled
    
    ;*----------------------------------------------------------------------------------|
    ;*---------------Available configuration settings for PIC18F26K22-------------------|
    ;*----------------------------------------------------------------------------------|
    ;
    ;  Oscillator Selection bits
    ;    CONFIG FOSC = RC	    ;111X External RC oscillator, CLKOUT function on RA6
    ;    CONFIG FOSC = ECLPIO6  ;EC oscillator (low power, &lt;500 kHz)
    ;    CONFIG FOSC = ECLP	    ;EC oscillator, CLKOUT function on OSC2 (low power, &lt;500 kHz)
    ;    CONFIG FOSC = ECMPIO6  ;EC oscillator (medium power, 500 kHz-16 MHz)
    ;    CONFIG FOSC = ECMP	    ;EC oscillator, CLKOUT function on OSC2 (medium power, 500 kHz-16 MHz)
    ;    CONFIG FOSC = INTIO7   ;Internal oscillator block, CLKOUT function on OSC2
    ;    CONFIG FOSC = INTIO67  ;Internal oscillator block
    ;    CONFIG FOSC = RCIO6    ;External RC oscillator
    ;    CONFIG FOSC = RC	    ;External RC oscillator, CLKOUT function on OSC2
    ;    CONFIG FOSC = ECHPIO6  ;EC oscillator (high power, &gt;16 MHz)
    ;    CONFIG FOSC = ECHP	    ;EC oscillator, CLKOUT function on OSC2 (high power, &gt;16 MHz)
    ;    CONFIG FOSC = HSMP	    ;HS oscillator (medium power 4-16 MHz)
    ;    CONFIG FOSC = HSHP	    ;HS oscillator (high power &gt; 16 MHz)
    ;    CONFIG FOSC = XT	    ;XT oscillator
    ;    CONFIG FOSC = LP	    ;LP oscillator
    ;
    ;*------------------------------------------------------------------------------------*|
    ;*                                                                                    *|
    ;*---------------------------------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
        
    ;*--------------------------------------------------------------------------------------------------------|
    ;*                                  | -------------------------- |                                        |
    ;*  -----------------------------   |  [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"
    
    OSCCON    = %01110000   ; 64Mhz
    OSCTUNE.6 = 1           ; Enable 4x PLL
    
    LED var PORTC.3
    
    
    main:
    high LED
    pause 10
    low LED
    pause 1000
    goto main
    Last edited by astanapane; - 1st July 2018 at 13:56.

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,795


    Did you find this post helpful? Yes | No

    Default Re: GPS Project: PIC18F26K22 or PIC18F46K22

    pause 10 is too little time.

    Maybe you need to make this 1000.

    Then check with a timer that it actually pauses every 1 sec confirming that osc is setup correctly.

    Recently I had similar matter setting up system oscillator again with 4xPLL and was running slow. Richard got it and we are OK now.

    Ioannis

  6. #6
    Join Date
    Oct 2010
    Posts
    411


    Did you find this post helpful? Yes | No

    Default Re: GPS Project: PIC18F26K22 or PIC18F46K22

    Quote Originally Posted by Ioannis View Post
    pause 10 is too little time.

    Maybe you need to make this 1000.

    Then check with a timer that it actually pauses every 1 sec confirming that osc is setup correctly.

    Recently I had similar matter setting up system oscillator again with 4xPLL and was running slow. Richard got it and we are OK now.

    Ioannis
    Ioanni,

    thanks a lot for the help. I'll do it tonight and try to increase the time.

    To be honest i made many changing to the pause commands like : 10ms , 100ms, 1000ms, 2000ms. All seem to work fine.

    It would be a good practice to see how could we identify that the PIC clock now is running at 64Mhz?

    Is there any way to measure this with an Oscilloscope? I believe that this is a question have been asked many times.

    If someone could help me to identify the cpu clock speed of the PIC with the new setting of external 16Mhz crystal and 4xPLL, i can do the testing, and share the information step by step in here. If there is already posted an example like this i would like to have a look at it.

    thanks a lot.

Similar Threads

  1. PIC18F46K22 config issue
    By LGabrielson in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 29th September 2012, 04:20
  2. Replies: 1
    Last Post: - 27th July 2008, 07:14
  3. Pic GPS project Demo
    By Art in forum GPS
    Replies: 0
    Last Post: - 28th October 2007, 04:05
  4. GPS project question
    By mjp130 in forum GPS
    Replies: 6
    Last Post: - 4th July 2007, 21:09
  5. gps project
    By chuckad in forum GPS
    Replies: 2
    Last Post: - 9th February 2007, 03:52

Members who have read this thread : 4

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