External clock on 16f819 problem.


Closed Thread
Results 1 to 16 of 16

Hybrid View

  1. #1
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: External clock on 16f819 problem.

    Quote Originally Posted by Dave View Post
    Robert, Havent you ever ran a PIC from an external oscillator before? ...
    Always.


    Quote Originally Posted by Dave View Post
    ...You only need 1 pin for the input. ...
    Not wired like this:

    Name:  PIC schematic.JPG
Views: 2760
Size:  22.3 KB

    Robert
    Last edited by Demon; - 22nd January 2012 at 21:13.

  2. #2
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: External clock on 16f819 problem.

    No Robert, Like this:
    Name:  Ext Osc.JPG
Views: 1123
Size:  42.9 KB
    Dave Purola,
    N8NTA
    EN82fn

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


    Did you find this post helpful? Yes | No

    Default Re: External clock on 16f819 problem.

    Wouldn't that need a CONFIG fuse?

    Dave, do you have an example from one of your programs?

    Robert

    EDIT: These are the available fuses for a 16F819:

    Code:
    _CP_ALL                      EQU     H'1FFF'
    _CP_OFF	                     EQU     H'3FFF'
    _CCP1_RB2		     EQU     H'3FFF'
    _CCP1_RB3                    EQU     H'2FFF'
    _DEBUG_OFF                   EQU     H'3FFF'
    _DEBUG_ON                    EQU     H'37FF'
    _WRT_ENABLE_OFF              EQU     H'3FFF'
    _WRT_ENABLE_512              EQU     H'3DFF'
    _WRT_ENABLE_1024             EQU     H'3BFF'
    _WRT_ENABLE_1536             EQU     H'39FF'
    _CPD_ON                      EQU     H'3EFF'
    _CPD_OFF                     EQU     H'3FFF'
    _LVP_ON                      EQU     H'3FFF'
    _LVP_OFF                     EQU     H'3F7F'
    _BODEN_ON                    EQU     H'3FFF'
    _BODEN_OFF                   EQU     H'3FBF'
    _MCLR_ON		     EQU     H'3FFF'
    _MCLR_OFF                    EQU     H'3FDF'
    _PWRTE_OFF                   EQU     H'3FFF'
    _PWRTE_ON                    EQU     H'3FF7'
    _WDT_ON                      EQU     H'3FFF'
    _WDT_OFF                     EQU     H'3FFB'
    _EXTRC_CLKOUT		     EQU     H'3FFF'
    _EXTRC_IO		     EQU     H'3FFE'
    _INTRC_CLKOUT                EQU     H'3FFD'
    _INTRC_IO		     EQU     H'3FFC'
    _EXTCLK			     EQU     H'3FEF'
    _HS_OSC                      EQU     H'3FEE'
    _XT_OSC                      EQU     H'3FED'
    _LP_OSC                      EQU     H'3FEC'

    And these are the default settings (PM and MPASM):

    Code:
            device  pic16F819, hs_osc, wdt_on, pwrt_on, lvp_off, protect_off
            ...    else
            ...        __config _HS_OSC & _WDT_ON & _PWRTE_ON & _LVP_OFF & _CP_OFF
    Last edited by Demon; - 23rd January 2012 at 00:04. Reason: Used sample from proper PIC

  4. #4
    Join Date
    Dec 2011
    Location
    IO93ok
    Posts
    190


    Did you find this post helpful? Yes | No

    Default Re: External clock on 16f819 problem.

    To all intents and purposes a clock and oscillator are one and the same.

    The answer lies at the end of the fuses list 4th from bottom _EXTCLK needs setting as my programmer defaults to standard inc setting.

    This is what I need :

    _LVP_OFF & _CP_OFF & _BODEN_ON & _MCLR_OFF & _PWRTE_ON & _WDT_OFF & _EXTCLK & _DEBUG_OFF & _WRT_ENABLE_OFF & _CPD_OFF & _CCP1_RB3
    Last edited by tasmod; - 23rd January 2012 at 11:22.

  5. #5
    Join Date
    Dec 2011
    Location
    IO93ok
    Posts
    190


    Did you find this post helpful? Yes | No

    Default Re: External clock on 16f819 problem.

    Hmm, I posted another reply but it vanished into the ether !

  6. #6
    Join Date
    Dec 2011
    Location
    IO93ok
    Posts
    190


    Did you find this post helpful? Yes | No

    Default Re: External clock on 16f819 problem.

    OK, changing the INC file and putting that line in did the trick. Seems my programmer options don't work it always goes back to the standard INC, modifying that worked.

    The LCD now responds in a single line format but I seem to be screwed up with the ADCON TRIS etc. No surprise there then.

    I'll post the code once I have it from the other computer.

  7. #7
    Join Date
    Dec 2011
    Location
    IO93ok
    Posts
    190


    Did you find this post helpful? Yes | No

    Default Re: External clock on 16f819 problem.

    OK, this is the test code. Just trying to reproduce characters.

    The IN/OUTS ADC etc are there but there's no code to run them in this version.

    The ADCON1 register is setup and the LCD displays one line but I need to study up the rest TRIS etc.

    Code:
    '****************************************************************
    '*  Name    :                                      *
    '*  Author  : Rob Lane                                          *
    '*  Notice  :                                                   *
    '*          :                                                   *
    '*  Date    : 13/01/2012                                        *
    '*  Version : 1.0                                               *
    '*  Notes   : Using 16f819                                      *
    '*                                                              *
    '****************************************************************
    
    
    LCD_DB4    VAR PORTB.4 
    LCD_DB5    VAR PORTB.5 
    LCD_DB6    VAR PORTB.2 
    LCD_DB7    VAR PORTB.7 
    LCD_RS     VAR PORTA.2 
    LCD_E      VAR PORTA.3 
    
    LCD_Lines  CON 2 ' # of Lines on LCD, 1 or 2 (Note: use 2 for 4 lines) 
    LCD_DATAUS CON 50 ' Data delay time in us 
    LCD_COMMANDUS CON 2000 ' Command delay time in us
    clear
    
      ' Define ADCIN parameters
    Define	ADC_BITS	10	' Set number of bits in result
    Define	ADC_CLOCK	0	' Set clock source (Fosc/2)
    Define	ADC_SAMPLEUS	50	' Set sampling time in uS
    
    INCLUDE "LCD_AnyPin.pbp" ; *** Include MUST be AFTER LCD Pin assignments ****
    
    'setup the custom characters
    LCDOUT  $FE,$40,$01,$01,$01,$01,$01,$01,$01,$01  ' Cust Char #0 
    LCDOUT  $FE,$48,$1F,$11,$11,$11,$11,$11,$11,$11  ' Cust Char #1  
    LCDOUT  $FE,$50,$1F,$10,$10,$10,$10,$10,$10,$1F  ' Cust Char #2  
    LCDOUT  $FE,$58,$01,$01,$01,$01,$01,$01,$01,$1F  ' Cust Char #3  
    LCDOUT  $FE,$60,$1F,$11,$11,$11,$11,$11,$11,$1F  ' Cust Char #4  
    LCDOUT  $FE,$68,$11,$11,$11,$11,$11,$11,$11,$1F  ' Cust Char #5  
    LCDOUT  $FE,$70,$1F,$01,$01,$01,$01,$01,$01,$1F  ' Cust Char #6  
    LCDOUT  $FE,$78,$1F,$01,$01,$01,$01,$01,$01,$01  ' Cust Char #7 
    
    'setup the THICKER custom characters
    'LCDOUT  $FE,$40,$03,$03,$03,$03,$03,$03,$03,$03  ' Cust Char #0 
    'LCDOUT  $FE,$48,$1F,$1F,$1B,$1B,$1B,$1B,$1B,$1B  ' Cust Char #1  
    'LCDOUT  $FE,$50,$1F,$1F,$18,$18,$18,$18,$1F,$1F  ' Cust Char #2  
    'LCDOUT  $FE,$58,$03,$03,$03,$03,$03,$03,$1F,$1F  ' Cust Char #3  
    'LCDOUT  $FE,$60,$1F,$1F,$1B,$1B,$1B,$1B,$1F,$1F  ' Cust Char #4  
    'LCDOUT  $FE,$68,$1B,$1B,$1B,$1B,$1B,$1B,$1F,$1F  ' Cust Char #5  
    'LCDOUT  $FE,$70,$1F,$1F,$03,$03,$03,$03,$1F,$1F  ' Cust Char #6  
    'LCDOUT  $FE,$78,$1F,$1F,$03,$03,$03,$03,$03,$03  ' Cust Char #7 
    
    nPos  var byte
    nDig  var byte
    in_count  var word
    tr_out  var word
    batt_volt  VAR BYTE
    
    batt_adc var porta.0
    freq_in var portb.6
    freq_lockout var portb.3
    
    'TRISA=%10001101
    'TRISB=%01000000
    'ADCON0=%00000000
    ADCON1=%10001110   
    
    LOW PortB.0  		 ;r/w lcd line
    
    'CONFIGURE DISPLAY 
    pause 1000
    ln1 con $80
    ln2 con $C0
    CS  con 1
    pause 500
    LCDOUT $FE,1
    
    lcdout $fe, CS            ' Clear screen
    
    main:  
    	nDig=1 : npos=0 : gosub displaydigit  
    	nDig=2 : npos=1 : gosub displaydigit
        nDig=3 : npos=2 : gosub displaydigit
        nDig=4 : npos=3 : gosub displaydigit
        lcdout $FE,$80+6,"Test" 
       		
    goto main
      
    
    displaydigit:
    if ndig=0 then gosub zero
    if ndig=1 then gosub One
    if ndig=2 then gosub Two
    if ndig=3 then gosub Three
    if ndig=4 then gosub Four
    if ndig=5 then gosub Five
    if ndig=6 then gosub Six
    if ndig=7 then gosub Seven
    if ndig=8 then gosub Eight
    if ndig=9 then gosub nine
    return
       	
    Zero:
    	LCDOUT $FE,$80+nPos,1
    	LCDOUT $FE,$C0+nPos,5
    return
    
    One:
    	LCDOUT $FE,$80+nPos,0
    	LCDOUT $FE,$C0+nPos,0
    return
    
    Two:
    	LCDOUT $FE,$80+nPos,7
    	LCDOUT $FE,$C0+nPos,2
    return
    
    Three:
    	LCDOUT $FE,$80+nPos,6
    	LCDOUT $FE,$C0+nPos,3
    return
    
    Four:
    	LCDOUT $FE,$80+nPos,5
    	LCDOUT $FE,$C0+nPos,0
    return
    
    Five:
    	LCDOUT $FE,$80+nPos,2
    	LCDOUT $FE,$C0+nPos,3
    return
    
    Six:
    	LCDOUT $FE,$80+nPos,2
    	LCDOUT $FE,$C0+nPos,5
    return
    
    Seven:
    	LCDOUT $FE,$80+nPos,7
    	LCDOUT $FE,$C0+nPos,0
    return
    
    Eight:
    	LCDOUT $FE,$80+nPos,4
    	LCDOUT $FE,$C0+nPos,5
    return
    
    Nine:
    	LCDOUT $FE,$80+nPos,4
    	LCDOUT $FE,$C0+nPos,3
    return
    
        
    
    end

Members who have read this thread : 0

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