Menu

From 16F690 to 18F06Q20 - first things first: THE blinker (LED flasher)

Flotul
2024-11-29
2024-12-05
  • Flotul

    Flotul - 2024-11-29

    Hi,

    I'd like to move from 16F690 to 18F06Q20.

    So, like all "beginners" are told to do, I start with THE blinker.

    While everything runs smoothly with the 16F690, for any reasons, with the second chip, nothing does really work well (see comments in code).

    Any clue why?

    ' both chip tested with 20MHz crystal
    #chip 16F690, 20
    '#chip 18F06Q20, 20
    
    #define LED PORTC.3
    
    ' 16F690 = ok
    ' 18F06Q20 = LED blinks but time (ms) is totally out of range - 10x..20x times slower
    Do
        LED = 1
        Wait 500 ms
        LED = 0
        Wait 500 ms
    Loop
    
    // ' 16F690 = ok
    // ' 18F06Q20 = no
    // Do
    //     LED = !LED
    //     Wait 500 ms
    // Loop
    
     
  • Anobium

    Anobium - 2024-11-29

    Check out my Q20 demos.

    Either download the latest demo pack or look on YouTube.

    You need apply power to VDDIO2. The Q20 have two power domains. When using the 2nd power domain you must provide VDDIO2

     
  • William Roth

    William Roth - 2024-12-03

    Try this and tell us what happens. Make sure that Vdd is tied to Vddio2 (Pins 1 & 8)

    #Chip 18F06Q20, 20
    #CONFIG FCMEN=ON
    #CONFIG FEXTOSC=HS      //' or try FEXTOSC=HS_24MHZ
    #CONFIG RSTOSC=EXTOSC
    
    Wait 100 ms
    
    #Define LED PortC.3
    Dir LED Out
    
    Do
         Set LED ON
         Wait 500 ms
         Set LED Off 
         Wait 500 ms
    Loop
    

    Edited to add additional option for FEXTOSC

     
    • Flotul

      Flotul - 2024-12-04

      That code works!!!

      The LED blinks with correct timing.

      Either options #CONFIG FEXTOSC=HS or FEXTOSC=HS_24MHZ will work too.

      After a few trials, those two lines are a must to make it work:
      . #CONFIG FEXTOSC=HS
      . #CONFIG RSTOSC=EXTOSC

      Thanks a lot 😉

       
      • Anobium

        Anobium - 2024-12-04

        The config will have no impact as the chip is initialised without that config.

        Post your GCB and ASM file. This makes little sense to me.

         
  • Anobium

    Anobium - 2024-12-04

    There is a whole suite of demos for this chip. See the demos folders. A quick search in GCCODE or Explorer for Q20.* will show 49 demos specific to this chip family. As the 16Q20 is the big memory version of the 06Q20 - the demos will work.

    Specific to the Q20 and Q24 the VDDIO2 and/or VDDI03 power is require when using the power domain associated with VDDIO2 and/or VDDI03. The demo programs show this is required.

     
  • William Roth

    William Roth - 2024-12-04

    OP code is missing port direction for PortC.3.

     Dir PortC.3 Out
    
     
  • Flotul

    Flotul - 2024-12-04

    Anobium, I have already powered the Q20 according to the DS. But there's no change at all.

    Either download the latest demo pack or look on YouTube. I have also already been looking for examples but, sorry, can't seem to be able to find any of them 😔

     
  • William Roth

    William Roth - 2024-12-05

    The demos for the Q20 are located in the folder:

    ...Vendor_Boards\Great_Cow_Basic_Demo_Board\18Fx6q20_ChipRange_Demonstrations\

    However none of these show the use of an external crystal or the any specific config settings that may be required for this range of chips. ( the default settings seem good)

    As I previously noted, your code is missing the Dir command for the Port.pin

    My suggestion (for testing) would be to use the internal oscillator and to also set the port direction( required).

    #chip 18F06Q20, 16   // internal osc @ 16MHz
    #option explicit
    
    Dir PortC.3 Out      // required
    
    Wait 200 ms          // allow time for chip to stabilize
    
    Do
         Set PortC.3 on
         Wait 500 ms
         Set PortC.3 off
         Wait 500 ms
    Loop
    

    If this works then your issue is related to either the missing PortC.3 Dir command or the external osc setup.

    William

     
  • Flotul

    Flotul - 2024-12-05

    Here are my asm and gcb files

     
  • Flotul

    Flotul - 2024-12-05

    William,

    Your code works perfectly; thank you.

    If this works then your issue is related to either the missing PortC.3 Dir command or the external osc setup.

    The DIR command won't change anything and I'm not yet sure how to set the external oscillator - I assume it is #CONFIG FEXTOSC=HS. I haven't been digging in the DS but right now, I don't know wath that config does #CONFIG RSTOSC=EXTOSC.

     
  • Flotul

    Flotul - 2024-12-05

    All of you give me infos where to find demo codes and examples and I'm still not able to find them.

    To be fully honest, I'm completely confused in this SourceForge website. I hardly find my own threads, I don't find the directories you mention neither the files you're talking about. To me, the appearance of this forum is so different from all others that I'm quite lost and I apologize.

    Where EXACTLY are the 49 files in GCCODE directory, where is "...Vendor_Boards\Great_Cow_Basic_Demo_Board\18Fx6q20_ChipRange_Demonstrations\" to be found???? Is it in this site or somewhere else?

    It's frustrating seeing you wanting to help me and not being able to achieve such simple searches...

     
  • Anobium

    Anobium - 2024-12-05

    You may not have installed the Demos. We removed from the installation as requested by the users.

    To install. Open GCSTUDIO and to the right of the About label there is 'Install or Update Demonstration Sources'. That will commence the download, when downloaded, install from your download directory. Does that work for you?

     
  • Flotul

    Flotul - 2024-12-05

    Just downloaded the file but I get an error (see attachment).

    Maybe it's time for me to reinstall GCStudio as by default, in the root instead as \Program Files (x86)...

     
    • Anobium

      Anobium - 2024-12-05

      Yes, the default folders are always best for the 3rd party applications.

       
  • Flotul

    Flotul - 2024-12-05

    Okay, all demos are finally there! 👍

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.