Works on 16F but not on 18F - what am I missing?


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2013
    Posts
    3

    Default Works on 16F but not on 18F - what am I missing?

    I've learned lots from this forum - thanks everyone. But now I have a specific problem I cant find an answer to...

    I've been coding away happily on a 16F1937, but have hit the array size limit for my program.



    I bought an 18F45K80 but cant get it to work. I went right back to a hello world blinking LED with blink.pbp from the examples folder - got it working in a circuit with the 16F and then recompiled etc targeting the 18F and put it in the known working circuit. No luck.



    Is there something I need to include on the circuit to accommodate the new chip? Something in the code that needs to be changed?



    Here is the code:
    Code:
    ' Name        : BLINK.pbp
    ' Compiler    : PICBASIC PRO Compiler 2.6
    ' Assembler   : PM or MPASM
    ' Target PIC  : 16F or 18F types
    ' Hardware    : Non specific
    ' Oscillator  : internal or external
    ' Keywords    : BLINK LED
    ' Description : PICBASIC PRO program to to blink an LED connected
    ' to PORTB.0 about once a second
    '
    
    'The following program is a simple test to blink an LED on and off.  Select a
    'device in the dropdown list above, then click the Compile Only button on the 
    'toolbar to compile the program and generate a hex file.
    
    ' Configure pins for digital operation (uncomment as needed).
    ' These settings are intended as simple examples.  For more detail,
    ' see the appropriate device datasheet for register descriptions.
    'ANSEL =  000000  ' 16F88, 16F688, 16F690, 16F88x
    'ANSELH = 000000  ' 16F690, 16F88x
    'ADCON1 = 000111  ' 16F87x, 16F87xA, 18F452
    'ADCON1 = 001111  ' 18F4620 
    
    TRISB = 0
    
    LED    VAR  PORTB.0   ' Assign name "LED" to PORTB.0
    
    mainloop:
       High LED        ' Turn on LED connected to PORTB.0
       Pause 500       ' Delay for .5 seconds
    
       Low LED         ' Turn off LED connected to PORTB.0
       Pause 500       ' Delay for .5 seconds
    
       Goto mainloop   ' Go back to loop and blink LED forever
       
       End
    I took a pictr of the breadboard layout, but I'm having trouble getting it onto the board - I'll update if I manage it.

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: Works on 16F but not on 18F - what am I missing?

    Try ADCON1 = 15 to set to all digital. It looks like portb.0 is an analog pin.

  3. #3
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,588


    Did you find this post helpful? Yes | No

    Default Re: Works on 16F but not on 18F - what am I missing?

    Config settings are the only difference using an 18F with v2.6 (I have v2.60c).

    There are no changes to circuitry, Blinky should work.

    18F have a lot more config settings available though.

    Robert

    Edit: is the default osc settings the same with this 18F?

  4. #4
    Join Date
    Jul 2013
    Posts
    3


    Did you find this post helpful? Yes | No

    Default Re: Works on 16F but not on 18F - what am I missing?

    Thanks for the replies

    Quote Originally Posted by peterdeco1 View Post
    Try ADCON1 = 15 to set to all digital. It looks like portb.0 is an analog pin.
    Tried that last night - with and with out the TRISB statement also
    also tried a different pin (D0)
    No luck.

    I have another chip (min order qty 2) so I'll try that tonight. I assumed if it programmed OK it wasn't dead...

  5. #5
    Join Date
    Jul 2013
    Posts
    3


    Did you find this post helpful? Yes | No

    Default Re: Works on 16F but not on 18F - what am I missing?

    Quote Originally Posted by Demon View Post
    Config settings are the only difference using an 18F with v2.6 (I have v2.60c).

    There are no changes to circuitry, Blinky should work.

    18F have a lot more config settings available though.

    Robert

    Edit: is the default osc settings the same with this 18F?
    Hmm, I'll mess around with putting an oscillator on the circuit too. Thanks.

Similar Threads

  1. DEFINE ADC_CLOCK for 16F PICs
    By RussMartin in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 26th January 2010, 13:56
  2. 16F to 18F transition pains
    By lurker in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 5th December 2008, 02:35
  3. changing code from 16F to 18F microprocessor
    By SCC_699 in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 14th May 2008, 14:27
  4. 16F to 18F context saving differences
    By brittons in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 1st April 2007, 04:40
  5. Upgrading 16F to 18F
    By Ron Marcus in forum General
    Replies: 1
    Last Post: - 29th March 2006, 10:44

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