18F4580 settings


Closed Thread
Results 1 to 16 of 16

Hybrid View

  1. #1
    malc-c's Avatar
    malc-c Guest

    Default 18F4580 settings

    I have some code which runs fine on a 16F877A but now want to migrate this to an 18F4580.

    I've taken the config settings from some code I have for an 18F4550

    Code:
    ASM  ; 18F2550/4550, 20mhz crystal
       __CONFIG    _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
       __CONFIG    _CONFIG1H, _FOSC_HSPLL_HS_1H
       __CONFIG    _CONFIG2L, _PWRT_ON_2L & _BOR_OFF_2L & _VREGEN_ON_2L
       __CONFIG    _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
       __CONFIG    _CONFIG3H, _PBADEN_OFF_3H
      __CONFIG    _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
    ENDASM
    and then remmed out the comments in the 18F4580.INC file that's in the PBP folder

    ;************************************************* ***************
    ;* 18F4580.INC *
    ;* *
    ;* By : Leonard Zerman, Jeff Schmoyer *
    ;* Notice : Copyright (c) 2008 microEngineering Labs, Inc. *
    ;* All Rights Reserved *
    ;* Date : 09/15/08 *
    ;* Version : 2.60 *
    ;* Notes : *
    ;************************************************* ***************
    NOLIST
    ifdef PM_USED
    LIST
    "Error: PM does not support this device. Use MPASM."
    NOLIST
    else
    LIST
    LIST p = 18F4580, r = dec, w = -311, w = -230, f = inhx32
    INCLUDE "P18F4580.INC" ; MPASM Header
    ;__CONFIG _CONFIG1H, _OSC_HS_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
    ;__CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
    ;__CONFIG _CONFIG3H, _PBADEN_OFF_3H & _LPT1OSC_OFF_3H & _MCLRE_ON_3H
    ;__CONFIG _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _BBSIZ_1024_4L & _XINST_OFF_4L
    NOLIST
    endif
    LIST
    EEPROM_START EQU 0F00000h
    BLOCK_SIZE EQU 8
    Yet I can't get it to compile via MPSAM.

    It comes up with "symbol not previously defined _config1l" etc which you normally get when these lines are not remmed out.

    Can anyone suggest the correct config settings

  2. #2
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    OK remming out the offending lines in MCS

    Code:
    ASM  ; 18F2550/4550, 20mhz crystal
    ;   __CONFIG    _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
    ;  __CONFIG    _CONFIG1H, _FOSC_HSPLL_HS_1H
       __CONFIG    _CONFIG2L, _PWRT_ON_2L  
       __CONFIG    _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
       __CONFIG    _CONFIG3H, _PBADEN_OFF_3H
      __CONFIG    _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
    ENDASM
    
    'DEFINE  OSC 20
    DEFINE  OSC 48
    works, however loading the code into the pic results in nothing being displayed on the LCD (must be a timing issue)... I'll try some further examples of code that Darrel and I had working on an 18F4550 and see if I can get that working

  3. #3
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Config options and definitions vary from one device type to the next, so you can't always get away with cut & paste config options.

    Just look in the P18F4580.INC file in your MPASM directory for a complete list of options available for each device type.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  4. #4
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Bruce, to be honest I don't have the understanding of these devices to really appreciate the info in that INC file...

    Here's my logic... for what its worth.

    The attached code works with a DS1307 module when using a 16F877A with just two small changes, namely the config settings are set to
    Code:
    @   __config _HS_OSC & _WDT_ON & _LVP_OFF & _CP_OFF
    And the OSC value set to 20

    I swapped the PIC for an 18F4580, changed the OSC value to 48 and the config settings to
    Code:
    ASM 
    ;  __CONFIG    CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L
    ;  __CONFIG    _CONFIG1H, _FOSC_HSPLL_HS_1H
      __CONFIG    _CONFIG2L, _PWRT_ON_2L  
      __CONFIG    _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
      __CONFIG    _CONFIG3H, _PBADEN_OFF_3H
      __CONFIG    _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
    ENDASM
    It compiles with no errors, loads into the PIC, but the LCD is blank. Both chips used RC3 and RC4 for the Ic2 (SCL and SDA) and I've tried changing OSC to 20 instead of 48 but it still fails to display anything (even garbage) on the LCD.

    Why is life so difficult.... !
    Attached Files Attached Files
    Last edited by malc-c; - 26th March 2010 at 21:50.

  5. #5
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Well the PIC's working with those settings - I went back to basics and wrote the following simple basic "hello world" type code.

    Code:
    ASM  ; 18F2550/4550, 20mhz crystal
    ;  __CONFIG    CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L
    ;  __CONFIG    _CONFIG1H, _FOSC_HSPLL_HS_1H
      __CONFIG    _CONFIG2L, _PWRT_ON_2L  
      __CONFIG    _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
      __CONFIG    _CONFIG3H, _PBADEN_OFF_3H
      __CONFIG    _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
    ENDASM
    
    DEFINE  OSC 48
    
    clear
    
    ;----[LCD definitions]------------------------------------------------------
    DEFINE LCD_DREG  PORTB          ' LCD Data port
    DEFINE LCD_DBIT  0              ' starting Data bit (0 or 4)
    DEFINE LCD_EREG  PORTB          ' LCD Enable port
    DEFINE LCD_EBIT  5              '     Enable bit  (on EasyPIC 5 LCD)
    DEFINE LCD_RSREG PORTB          ' LCD Register Select port
    DEFINE LCD_RSBIT 4              '     Register Select bit   (on EasyPIC 5 LCD)
    DEFINE LCD_BITS  4              ' LCD bus size (4 or 8 bits)
    DEFINE LCD_LINES 4              ' number of lines on LCD
    DEFINE LCD_COMMANDUS 2000       ' Command delay time in us 
    DEFINE LCD_DATAUS 50            ' Data delay time in us
    
    ;---------------------------------------------------------------------------
    
    	
    counter var byte
    for counter = 1 to 10
    LCDOut $FE,2,"Number = ",dec counter
    pause 10
    next
    This displays "Number = " and counts from 1 to 10 on the LCD

    I've looked at the datasheet, but can't see anything obvious other than making the correct pins on Port C input or outputs (something I would of thought would of ported over from the code)

    Any suggestions

  6. #6
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Well expanding on the first test I now have data being read from the RTC module

    Code:
    ASM  ; 18F2550/4550, 20mhz crystal
    ;  __CONFIG    CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L
    ;  __CONFIG    _CONFIG1H, _FOSC_HSPLL_HS_1H
      __CONFIG    _CONFIG2L, _PWRT_ON_2L  
      __CONFIG    _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
      __CONFIG    _CONFIG3H, _PBADEN_OFF_3H
      __CONFIG    _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
    ENDASM
    
    DEFINE  OSC 48
    
    clear
    
    ;----[LCD definitions]------------------------------------------------------
    DEFINE LCD_DREG  PORTB          ' LCD Data port
    DEFINE LCD_DBIT  0              ' starting Data bit (0 or 4)
    DEFINE LCD_EREG  PORTB          ' LCD Enable port
    DEFINE LCD_EBIT  5              '     Enable bit  (on EasyPIC 5 LCD)
    DEFINE LCD_RSREG PORTB          ' LCD Register Select port
    DEFINE LCD_RSBIT 4              '     Register Select bit   (on EasyPIC 5 LCD)
    DEFINE LCD_BITS  4              ' LCD bus size (4 or 8 bits)
    DEFINE LCD_LINES 4              ' number of lines on LCD
    DEFINE LCD_COMMANDUS 2000       ' Command delay time in us 
    DEFINE LCD_DATAUS 50            ' Data delay time in us
    
    ;---------------------------------------------------------------------------
    
    
    RTCYear	Var	Byte
    RTCMonth Var Byte
    RTCDate	Var	Byte
    RTCDay	Var	Byte
    RTCHour	Var	Byte
    RTCMin	Var	Byte
    RTCSec	Var	Byte
    RTCCtrl Var	Byte
    
    SDA	Var	PORTC.4
    SCL	Var	PORTC.3
    
    main:
    I2CRead SDA,SCL,$D0,$00,[RTCSec,RTCMin,RTCHour,RTCDay,RTCDate,RTCMonth,RTCYear,RTCCtrl]
    Lcdout $fe, 2,hex2 RTCDate, "/",hex2 RTCMonth, "/" , hex2 RTCYear,_
    		"  ", hex2 RTCHour, ":", hex2 RTCMin, ":", hex2 RTCSec
    goto main:
    So now just have to work out why the original code that worked with the 16F877A didn't / doesn't port across ?

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