Confusion with 18F45K80 config, maybe someone has working one?


Closed Thread
Results 1 to 10 of 10
  1. #1
    Join Date
    Feb 2013
    Posts
    1,078

    Default Confusion with 18F45K80 config, maybe someone has working one?

    Hello. Trying to blink a led using 18F45k80.
    Seems that I have some config issue, since it does not works on any of the pins - voltage there is around 1.8--2.5v, and does not change. Here's my code. What I'm doing wrong?

    Code:
    ;----[18F45K80 Hardware Configuration]------------------------------------------
    #IF __PROCESSOR__ = "18F45K80"
      #DEFINE MCU_FOUND 1
    #CONFIG
      CONFIG  RETEN=ON, INTOSCSEL=HIGH, SOSCSEL=HIGH, XINST=OFF, FOSC=HS1, PLLCFG=ON
      CONFIG  FCMEN=OFF, IESO=OFF, PWRTEN=OFF, BOREN=SBORDIS, BORV=3, BORPWR=ZPBORMV
      CONFIG  WDTEN=SWDTDIS, WDTPS=512, CANMX=PORTB, MSSPMSK=MSK7, MCLRE=OFF
      CONFIG  STVREN=ON, BBSIZ=BB2K, CP0=OFF, CP1=OFF, CP2=OFF, CP3=OFF, CPB=OFF
      CONFIG  CPD=OFF, WRT0=OFF, WRT1=OFF, WRT2=OFF, WRT3=OFF, WRTC=OFF, WRTB=OFF
      CONFIG  WRTD=OFF, EBTR0=OFF, EBTR1=OFF, EBTR2=OFF, EBTR3=OFF, EBTRB=OFF
    #ENDCONFIG
    
    
    #ENDIF
    
    
    ;----[Verify Configs have been specified for Selected Processor]----------------
    ;       Note: Only include this routine once, after all #CONFIG blocks
    #IFNDEF MCU_FOUND
      #ERROR "No CONFIGs found for [" + __PROCESSOR__ +"]"
    #ENDIF
    
    
    osccon=%11111111
    DEFINE OSC 16
    
    
    ANCON1=0 'DISABLE ADC D3-D2-D1-D0-
    TRISC=%00000000 'set PORTC as output all
    TRISD=%00000000 'set PORTD as output all
    TRISB=%00000000 'set PORTB as output all
    TRISA=%00000000 
    TRISE=%0000000  'set PORTE as output all
    
    GKO:
    HIGH PORTa.0
    PAUSE 2000
    LOW PORTa.0
    PAUSE 2000
    GOTO GKO

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default Re: Confusion with 18F45K80 config, maybe someone has working one?

    First, turn off analog functionality on the pins you're trying to use (PORTA.0 for example).
    Second, not all pins on that device has the same drive strength. PortA should be able to drive a LED though.

    I have not looked at the oscillator settings but if the above does not help that would be my next thing to check.

  3. #3
    Join Date
    Apr 2014
    Location
    OK
    Posts
    557


    Did you find this post helpful? Yes | No

    Default Re: Confusion with 18F45K80 config, maybe someone has working one?

    At 1.8 to 2.5 VREF, you may not have enough voltage for the LED. Try at 5 volts and see if it's switching properly.

  4. #4
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Confusion with 18F45K80 config, maybe someone has working one?

    I'm feeding it with 5 volts.
    I tried to check voltages with multimeter, without the LED, all the same.
    Tried each pin of each port...

  5. #5
    Join Date
    Aug 2011
    Posts
    412


    Did you find this post helpful? Yes | No

    Default Re: Confusion with 18F45K80 config, maybe someone has working one?

    Judging from your settings I'm going to assume you're trying to use the INTOSC.

    If so, you need to set the CONFIG to use it. That's what controls what happens at powerup...
    trying to setting the OSCCON register is a run-time setting, so it relies on the thing running in the first place.

    The default INTOSC setting is 8MHz, so it'll run at that speed until you change it with OSCCON.


    Try this:
    Code:
      CONFIG  RETEN=ON, INTOSCSEL=HIGH, SOSCSEL=HIGH, XINST=OFF, FOSC=INTIO2, PLLCFG=OFF
    
    'then later you can change it
    OSCCON = $70     ' IRFC[2:0] = 111 (16MHz), SCS[1:0] = 00 (primary CONFIG osc setting)
    ' set PLLEN (optional, 4x16MHz=64MHz)
    'OSCTUNE.6 = 1

  6. #6
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Confusion with 18F45K80 config, maybe someone has working one?

    Thanks!
    I will try it today later.
    I want to run it at 16mhz and then try 64mhz, to see if there's any practical difference in i2cread and shiftout statements, since on 16F, oscillator speed has no impact on these statement speed, which is around 50khz, whenever oscillator is 4mhz or 16mhz.

  7. #7
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Confusion with 18F45K80 config, maybe someone has working one?

    Code:
    #CONFIG
      CONFIG  RETEN=ON, INTOSCSEL=HIGH, SOSCSEL=HIGH, XINST=OFF, FOSC=INTIO2, PLLCFG=OFF
    #ENDCONFIG
    
    'then later you can change it
    OSCCON = $70     ' IRFC[2:0] = 111 (16MHz), SCS[1:0] = 00 (primary CONFIG osc setting)
    ' set PLLEN (optional, 4x16MHz=64MHz)
    OSCTUNE.6 = 1
    DEFINE OSC 16
    'ANSELE=%00000000 'enable adc input porte.2
    'ANSELA=%00000010 'disable ADC on A
    'ANSELB=%00000000 'disable ADC on B
    'ANSELD=%00000000 'disable ADC on D
    ANCON1=0 'DISABLE ADC D3-D2-D1-D0-
    TRISC=%00000000 'set PORTC as output all           0.
    
    TRISD=%00000000 'set PORTD as output all
    TRISB=%00000000 'set PORTB as output all
    TRISA=%00000000 'set PORTA 2 as input, others as output
    TRISE=%0000000  'set PORTE as output all
    
    
    GKO:
    HIGH PORTd.0
    PAUSE 2000
    LOW PORTd.0
    PAUSE 2000
    GOTO GKO
    Still does not work. In this example, PORTD.0 measures 2.5 volt and does not change.
    same to any other port.
    Last edited by CuriousOne; - 13th October 2022 at 09:09.

  8. #8
    Join Date
    Aug 2011
    Posts
    412


    Did you find this post helpful? Yes | No

    Default Re: Confusion with 18F45K80 config, maybe someone has working one?

    Sorry, I didn't mean for you to get rid of the other CONFIG settings... just change the OSC ones.

    Here's a complete example
    Code:
    #CONFIG
      CONFIG  RETEN=ON, INTOSCSEL=HIGH, SOSCSEL=HIGH, XINST=OFF, FOSC=INTIO2, PLLCFG=OFF
      CONFIG  FCMEN=OFF, IESO=OFF, PWRTEN=OFF, BOREN=SBORDIS, BORV=3, BORPWR=ZPBORMV
      CONFIG  WDTEN=SWDTDIS, WDTPS=512, CANMX=PORTB, MSSPMSK=MSK7, MCLRE=OFF
      CONFIG  STVREN=ON, BBSIZ=BB2K, CP0=OFF, CP1=OFF, CP2=OFF, CP3=OFF, CPB=OFF
      CONFIG  CPD=OFF, WRT0=OFF, WRT1=OFF, WRT2=OFF, WRT3=OFF, WRTC=OFF, WRTB=OFF
      CONFIG  WRTD=OFF, EBTR0=OFF, EBTR1=OFF, EBTR2=OFF, EBTR3=OFF, EBTRB=OFF
    #ENDCONFIG
    
    'then later you can change it
    OSCCON = $70     ' IRFC[2:0] = 111 (16MHz), SCS[1:0] = 00 (primary CONFIG osc setting)
    ' set PLLEN (optional, 4x16MHz=64MHz)
    OSCTUNE.6 = 1
    
    'with PLLEN=1 
    DEFINE OSC 64
    'with PLLEN=0
    'DEFINE OSC 16
    
    ANCON0=0	' digital IO AN7-AN0
    ANCON1=0 	' digital IO AN8-AN14
    
    TRISC=%00000000 'set PORTC as output all
    TRISD=%00000000 'set PORTD as output all
    TRISB=%00000000 'set PORTB as output all
    TRISA=%00000000 'set PORTA as output all
    TRISE=%0000000  'set PORTE as output all
    
    
    GKO:
    HIGH PORTD.0
    PAUSE 2000
    LOW PORTD.0
    PAUSE 2000
    GOTO GKO
    If you're using a DVM and measuring 2.5V, that probably means the pin is toggling but it's too fast for the meter,
    so the 'DEFINE OSC' doesn't match your actual settings and the 'PAUSE' is wrong.

    Try increasing the pause time to 5000 or 10000

    I want to run it at 16mhz and then try 64mhz, to see if there's any practical difference in i2cread and shiftout statements
    You'll see a difference, but it likely won't be earth shattering.
    To really effect the I2C speed you'd need to switch to using the MSSP hardware, and while that SHOUT routine I posted is faster than shiftout, it won't be as fast as using the SPI peripheral.

  9. #9
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Confusion with 18F45K80 config, maybe someone has working one?

    I will try to check it with scope next week, but my multimeter is Amprobe PM55A, it can do 5 samples per second and actually works even with pause 200

    MSSP might be good, but I was not able to run any of code samples given here on 16F series and I was not able to start any 18F series chip at all

  10. #10
    Join Date
    Aug 2011
    Posts
    412


    Did you find this post helpful? Yes | No

    Default Re: Confusion with 18F45K80 config, maybe someone has working one?

    Just try changing the on-off pause statements so that it's not 50 % duty cycle.
    Pause 2000, pause 6000 or pause 6000,pause 2000 should get you a different reading if the output is actually changing.

Similar Threads

  1. RS-232 confusion
    By Christopher4187 in forum General
    Replies: 11
    Last Post: - 17th March 2015, 15:16
  2. Servo confusion
    By Ramius in forum General
    Replies: 3
    Last Post: - 28th May 2012, 00:41
  3. setting config fuses not working
    By queenidog in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 23rd April 2012, 14:30
  4. HPWM confusion
    By lerameur in forum General
    Replies: 12
    Last Post: - 5th November 2006, 10:09
  5. HPWM confusion
    By rossfree in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 3rd November 2005, 16:50

Members who have read this thread : 2

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