16f818 from 16f628a


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    May 2012
    Location
    Merseyside, UK
    Posts
    237

    Angry 16f818 from 16f628a

    Hi....

    Help !!!!

    Have just ported a program fom 16f628 to 16f818 but nw it wont go....
    reason for porting was needing faster clock speed 818 can go at 20Megs 628 only 4 !

    having spent morning getting nowhere thought I would blink an LED... Easy !!

    No Joy.... So somthing wrong with my config. But what ???

    INC File :- I am using MPASM!

    Code:
    ;****************************************************************
    ;*  16F818.INC                                                  *
    ;*                                                              *
    ;*  By        : Leonard Zerman, Jeff Schmoyer                   *
    ;*  Notice    : Copyright (c) 2004 microEngineering Labs, Inc.  *
    ;*              All Rights Reserved                             *
    ;*  Date      : 01/07/04                                        *
    ;*  Version   : 2.45                                            *
    ;*  Notes     :                                                 *
    ;****************************************************************
            NOLIST
        ifdef PM_USED
            LIST
            include 'M16F81x.INC'    ; PM header
            device  pic16F818, hs_osc, wdt_on, pwrt_on, lvp_off, protect_off
            XALL
            NOLIST
        else
            LIST
            LIST p = 16F818, r = dec, w = -302
            INCLUDE "P16F818.INC"    ; MPASM  Header
            __config _INTRC_CLKOUT & _PWRTE_ON & _LVP_OFF & _CP_OFF & _MCLRE_OFF
            NOLIST
        endif
            LIST
    CODE :-



    Code:
    ' Example program from manual to blink an LED
    
    DEFINE OSC 8    'Set oscillator in MHz
    
    trisa  = 0
    trisb  = 0
    adcon1 = 7  
    
    main: High PORTB.5       ' Turn on LED connected to PORT
          Pause 1000       ' Delay for 1 seconds
          Low PORTB.5          ' Turn off LED connected to PORT
          Pause 1000       ' Delay for 1 seconds
            
          Goto main   ' Go back to loop and blink LED forever
          End
    What is wrong here....... PLease help advise !!

    Thank you
    Last edited by andybarrett1; - 25th August 2014 at 12:25. Reason: typo

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


    Did you find this post helpful? Yes | No

    Default Re: 16f818 from 16f628a

    Hi,
    There are 628's available that are specified to run at 20MHz - i used one this weekend.
    With that said, your config for the 818 says INTRC which means you're running from the internal oscillator. Looking at the oscillator section of the datasheet it's clear that the internal oscillator defaults to 31.25kHz while you're telling the compiler that your chip is running at 8MHz - which it isn't. I notice this:
    Code:
    DEFINE OSC 8    'Set oscillator in MHz
    Please note that DEFINE OSC xxx does not SET the oscillator speed in any way. What it does is inform the compiler at which speed you intend to run the PIC so that it can calculate the proper delays etc. In this case you're telling the compiler that the PIC is operating at 8MHz when in fact it's operating at 31.25kHz. Your one second pause becomes a 256 second pause. I think that if you leave the circuit powered up long enough you will see the LED blink.

    /Henrik.

    EDIT: Add OSCCON = 112 to set the oscillator to 8MHz.
    EDIT2: As far as I can see all 16F628A's are specified to run at 20MHz.
    Last edited by HenrikOlsson; - 25th August 2014 at 13:35.

  3. #3
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,617


    Did you find this post helpful? Yes | No

    Default Re: 16f818 from 16f628a

    Halas ...

    reason for porting was needing faster clock speed 818 can go at 20Megs 628 only 4 !
    nor the 628 nor 818 have 20 Mhz INTERNAL available ...

    sooo, you just have to use an EXTERNAL XTAL in HS mode ...
    no need to choose an exotic number and try to port your program for it ... as the 628/04 easily can run @ 20 Mhz EXTERNAL ...

    ... Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  4. #4
    Join Date
    May 2012
    Location
    Merseyside, UK
    Posts
    237


    Did you find this post helpful? Yes | No

    Default Re: 16f818 from 16f628a

    Quote Originally Posted by HenrikOlsson View Post
    EDIT: Add OSCCON = 112 to set the oscillator to 8MHz.
    EDIT2: As far as I can see all 16F628A's are specified to run at 20MHz.
    Ahhhhhh…. I am hoping this maybe the answer …. Will try this later.

    Will let you know if it works.

    Am trying to get stuff going using internal RC clock…. Then can do drop in upgrade !

    TY

    Andy

  5. #5
    Join Date
    May 2012
    Location
    Merseyside, UK
    Posts
    237


    Did you find this post helpful? Yes | No

    Default Re: 16f818 from 16f628a

    Yes ….

    Was the clock misunderstand on my part!

    Thank you for pointers and help

    Andy

Similar Threads

  1. Interface for 16f818
    By davekav in forum Serial
    Replies: 4
    Last Post: - 17th April 2008, 11:33
  2. 3.3V not working with 16f818
    By jjohannson in forum General
    Replies: 3
    Last Post: - 8th March 2007, 20:53
  3. ERROR Compling 16F819...l but the 16F818 works fine
    By 4Lewis in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 21st April 2006, 06:47
  4. 16F818 ADCON question
    By peterdeco1 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 1st February 2006, 10:50
  5. .inc & .bas for 16f818 12fxx
    By a.majid in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 23rd March 2005, 06:49

Members who have read this thread : 0

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts