18f series chip locked up


+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2007
    Posts
    16

    Default 18f series chip locked up

    I recently wrote code for the 18F14K50 chip and it seemes that i cannot get the code to run at all. When i power up the board the LCD stays blank. I added the debug value write to eeprom just to see if the code was moving and when i read back the eeprom values on pickit 2 it shows that the value is not being written. I have posted the beginning of the code below. Any help at all would be much appreciated.

    \\code\\
    '************************** Configuration Registers ****************************
    @__CONFIG _CONFIG1H, _FOSC_XT_1H & _IESO_ON_1H ; Set for an External Crystal
    @__CONFIG _CONFIG2L, _PWRTEN_ON_2L & _BOREN_ON_2L ; Brown out detect set for OFF, Power On Timer set for OFF
    @__CONFIG _CONFIG2H, _WDTEN_OFF_2H ; WDT set for OFF
    @__CONFIG _CONFIG3H, _MCLRE_OFF_3H ; MCLR is disabled
    '@__CONFIG _CONFIG5L, _CP0_ON_5L & _CP1_ON_5L ' Code Protect Blocks 0-1 is enabled
    '@__CONFIG _CONFIG6L, _WRT0_ON_6L & _WRT1_ON_6L ' Write Protect Blocks 0-1 is enabled
    WDTCON = %00000000 ' Assures the WDT is disabled
    '************************** Configuration Registers ****************************

    '''''''''''''''''''''''''''''' Microchip Definitions '''''''''''''''''''''''''''
    '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''
    include "modedefs.bas"
    DEFINE OSC 4
    DEFINE SER2_BITS 9
    DEFINE ADC_BITS 10 ' set number of bits in result
    DEFINE ADC_CLOCK 5 ' set clock source
    DEFINE ADC_SAMPLEUS 50 ' set sampling time for microseconds
    DEFINE LCD_DREG PORTC ' set LCD DATA port
    DEFINE LCD_DBIT 0 ' set starting DATA bit (0 or 4) if 4-bit
    DEFINE LCD_RSREG PORTC ' Set LCD Register Select port
    DEFINE LCD_RSBIT 7 ' Set LCD Register Select bit
    DEFINE LCD_EREG PORTB ' Set LCD Enable port
    DEFINE LCD_EBIT 6 ' Set LCD Enable bit
    DEFINE LCD_BITS 4 ' Set LCD bus size (4 or 8 bits)
    DEFINE LCD_LINES 4 ' Set number of lines on LCD
    DEFINE LCD_COMMANDUS 1500 ' Set command delay time in us
    DEFINE LCD_DATAUS 10 ' Set data delay time in us
    '''''''''''''''''''''''''''''' Microchip Definitions '''''''''''''''''''''''''''
    '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''

    ''''''''''''''''''''''''''' Register Definitions '''''''''''''''''''''''''''''''
    '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''
    TRISA = %00011011 ' Register A has 4 buttons(UP,SET,FNC,open)
    TRISB = %10000000 ' Register B has 1 button(DN)
    TRISC = %00010011 ' Register C is all outputs(LCD Control)
    PORTA = %00000000 ' Initialize all registers to zero
    PORTB = %00000000
    PORTC = %00000000
    INTCON = %00000000 ' No Interupts on programmer software
    CCP1CON = %00001100
    OSCCON = %01011100 ' Setup the PWM module for single output on RC5
    ''''''''''''''''''''''''''' Register Definitions '''''''''''''''''''''''''''''''
    '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''


    ''''''''''''''''''''''''''' Variable Declarations ''''''''''''''''''''''''''''''
    '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''

    'INPUTS AND OUTPUTS
    UP_BUTTON VAR PORTA.0 'PIN 19 (A0)
    SET_BUTTON VAR PORTC.4 'PIN 6 (A2)
    FUNCTION_BUTTON VAR PORTA.3 'PIN 4 (A3)
    COMM_OUT VAR PORTB.4 'PIN 13
    DOWN_BUTTON VAR PORTB.7 'PIN 10 (A1)
    REMOTE_FNC_RESET VAR PORTB.5 'PIN 12
    LCD_DRIVE var PORTC.5

    'SETTINGS SET BY USER (PROGRAMMER)
    DUTY VAR WORD ' LCD CONTRAST SETTING (EEPROM - 2 & 3)
    TEST1_PROG_NUM VAR BYTE
    TEST1_OPERATING_PRESSURE VAR BYTE
    TEST1_PSI_DIFF VAR BYTE
    TEST1_CYCLE_TIME VAR BYTE
    TEST1_STABIL_TIME VAR BYTE
    TEST1_MAX_FILL_TIME VAR BYTE
    TEST1_MIN_PSI_PERCENT VAR BYTE
    TEST2_PROG_NUM VAR BYTE
    TEST2_OPERATING_PRESSURE VAR BYTE
    TEST2_PSI_DIFF VAR BYTE
    TEST2_CYCLE_TIME VAR BYTE
    TEST2_STABIL_TIME VAR BYTE
    TEST2_MAX_FILL_TIME VAR BYTE
    TEST2_MIN_PSI_PERCENT VAR BYTE

    'SOFTWARE VARIABLES
    TEST1_CHECKSUM VAR WORD ' USED TO MAKE SURE DATA WAS SENT WITH NO ERROR
    TEST2_CHECKSUM VAR WORD
    A0 VAR BYTE ' Byte Variables for Button Inputs
    A1 VAR BYTE
    A2 VAR BYTE
    A3 VAR BYTE
    i VAR BYTE
    DEBUG_VALUE var byte
    ''''''''''''''''''''''''''' Variable Declarations ''''''''''''''''''''''''''''''
    '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''


    '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''
    '''''''''''''''''''''''LCD Display Configuration''''''''''''''''''''''''''''''''

    ' 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32
    DATA 0, 0, 0, 0, 0, 0, 0, 0, 10, 1, 1, 1, 1, 10, 10, 1, 1, 1, 1, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    Data @ 224, "S","P","V","_","S","L","A","M","D","U","N","K","2 ","_","R","0","0"

    ' T2CON = %00000101 ' Turn on Timer2, Prescale=4

    '' Use formula to determine PR2 value for a 1KHz signal,
    '' 4MHz clock, and prescale=4. (4E6/(4*4*1E3))-1=249

    ' PR2 = 249 ' Set PR2 to get 1KHz out

    '' Use formula to determine CCPR1L:CCP1CON<5:4> value for
    '' ends of range 20% to 80%. (249+1)*4*0.2=200 (20% value)
    '' (249+1)*4*0.8=800 (80% value)
    ' READ 2, DUTY.HIGHBYTE
    ' READ 3, DUTY.LowBYTE
    ' Pause 10
    ' DUTY = DUTY
    ' CCP1CON.4 = duty.0 ' Store duty to registers as
    ' CCP1CON.5 = duty.1 ' a 10-bit word
    ' CCPR1L = DUTY >> 2
    ' duty = duty + 10 ' Increase duty cycle

    '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''
    '''''''''''''''''''''''LCD Display Configuration''''''''''''''''''''''''''''''''


    '-------------------------Program Starts Here-----------------------------------
    '-------------------------------------------------------------------------------

    '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''
    '''''''''''''''''''''''''Start Up Procedure'''''''''''''''''''''''''''''''''''''
    INITIALIZE:
    DEBUG_VALUE = 456
    LCD_DRIVE = 1
    A0 = %00000000
    A1 = %00000000
    A2 = %00000000
    A3 = %00000000
    TEST1_PROG_NUM = 1
    TEST2_PROG_NUM = 2
    write 30, DEBUG_VALUE
    pause 500

    RUN_START_SCREEN:
    GOSUB CLEAR_LCD
    LCDOUT " ", "Spartan SPV"
    LCDOUT $FE, $C0, " ", "Slamdunk 2"
    \\code\\

    Please help!

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default

    This is just a guess as I do not have that chip. I have not even upgraded PBP yet.

    Try changing the XT to HS in your configs.

    Another suggestion is to always start with a simple blinky program when working with a new chip or new set up. Put the LED on a non analog pin.

    The chip might be running but at the wrong speed. The blinky helps to find a problem like that.
    Dave
    Always wear safety glasses while programming.

Similar Threads

  1. ISD1700 series Winbond chipcorder
    By rickeybell in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 21st March 2010, 06:13
  2. PBP is driving me crazy trying to make an 18F chip blink
    By George in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 20th June 2008, 06:08
  3. TV Display Chip
    By zadok in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 17th April 2008, 22:17
  4. chip selection aid
    By PICMAN in forum General
    Replies: 4
    Last Post: - 21st February 2005, 18:33
  5. Why use an 18F chip
    By AndyP in forum General
    Replies: 3
    Last Post: - 16th August 2004, 16:38

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