debug issue?


Closed Thread
Results 1 to 4 of 4

Thread: debug issue?

  1. #1
    Join Date
    Jun 2004
    Posts
    18

    Default debug issue?

    I had a working project with a PIC18F2320 and decided to change it over to a PIC18F4685 for extra programming room and more pins.

    Once I changed my program for the chip and upgraded to PBP2.6A and meProg for MPASM so I could program it nothing has worked since.

    Anyone have an idea why this simple program returns.

    Power Up but nothing else.

    I can change address to x and it will return.
    Power Up
    0
    0
    0
    etc....

    Any help or insight would be appreciated. I have an upgraded copy of epic coming since this just doesn't make sense to me.

    '************************************************* ***************
    '* Name : HandHeld *
    '* Author : Brian Gennings *
    '* Notice : Copyright (c) 2005 [set under view...options] *
    '* : All Rights Reserved *
    '* Date : 2/11/2011 *
    '* Version : 1.0 *
    '* Notes : RF controlled unit *
    '* : *
    '************************************************* ***************

    DEFINE OSC 8

    ' ** Declare the Variables **

    DEFINE DEBUG_MODE 1 ' Send Inverted serial data with debug
    DEFINE DEBUG_REG PORTB ' Debug Port = PortB
    DEFINE DEBUG_BIT 5 ' Debug.bit = PortB.5
    'DEFINE DEBUGIN_BIT 1 'DebugIn.bit = PortB.1
    DEFINE DEBUG_BAUD 9600 ' Default baud rate = 9600
    DEFINE DEBUG_PACING 1000


    ' ** Declare A/D variables**

    AD_Result Var Word ' 10-bit result of A/D conversion
    Volts Var Word ' Holds the voltage after quantasizing

    Quanta Con 1250

    ' ** Define the bits within the ADCON0 register **
    CHS3 Var ADCON0.5
    CHS2 Var ADCON0.4 ' ADC channel select bit
    CHS1 Var ADCON0.3 ' ADC channel select bit
    CHS0 Var ADCON0.2 ' ADC channel select bit
    GO_DONE Var ADCON0.1 ' ADC Conversion status/ plus enable conversion-bit
    ADON Var ADCON0.0 ' ADC Enable bit: 1=enabled, 0=disabled.

    ' ** Define the bits within the ADCON1 register **
    VGFC1 Var ADCON1.5 ' Voltage reference AVSS
    VGFC0 Var ADCON1.4 ' Voltage reference AVDD
    PCFG3 Var ADCON1.3 ' ADC port configuration bit
    PCFG2 Var ADCON1.2 ' ADC port configuration bit
    PCFG1 Var ADCON1.1 ' ADC port configuration bit
    PCFG0 Var ADCON1.0 ' ADC port configuration bit

    ' ** Define the bits within the ADCON2 register **
    ADFM Var ADCON2.7 ' A/D format select
    ACQT2 Var ADCON2.5 ' A/D Acquistion time
    ACQT1 Var ADCON2.4 ' A/D Acquistion time
    ACQT0 Var ADCON2.3 ' A/D Acquistion time
    ADCS2 Var ADCON2.2 ' A/D conversion clock
    ADCS1 Var ADCON2.1 ' A/D conversion clock
    ADCS0 Var ADCON2.0 ' A/D conversin clock

    ADIE Var PIE1.6 ' ADC interrupt enable/disable
    ADIF Var PIR1.6 ' ADC interrupt flag
    PEIE Var INTCON.6 ' Peripheral interrupt enable/disable
    GIE Var INTCON.7 ' Global interrupt enable/disable


    INCLUDE "modedefs.bas"

    OSCTUNE = 0
    OSCCON = %01110000

    @ __CONFIG _CONFIG1H, _IESO_ON_1H & _OSC_IRCIO67_1H
    @ __CONFIG _CONFIG2L, _PWRT_ON_2L & _BOREN_BOHW_2L & _BORV_0_2L
    @ __CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_128_2H
    @ __CONFIG _CONFIG3H, _MCLRE_OFF_3H & _PBADEN_OFF_3H
    @ __CONFIG _CONFIG4L, _LVP_OFF_4L & _DEBUG_OFF_4L
    '@ __CONFIG _CONFIG5H, _CPD_ON_5H

    ' I/O definitions

    LED var PortC.5 'LED
    RFPower var porta.3
    T_R var porta.5
    RF_IN var portb.1
    shutdown var portb.3

    dat var Byte

    e var portc.6
    cd var portb.4
    rw var portb.2
    cs1 var portc.0
    cs2 var portc.1
    rst var portc.2
    blue var porte.2
    red var porta.2
    green var portc.7

    SDA VAR Porta.0 ' The port your SDA line is on
    SCL VAR Porta.1 ' The port your SCL line is on

    x_cor var word
    y_cor var word
    address var word


    'Variables



    x var byte
    y var byte
    j var word
    k var byte

    i var byte



    size var byte
    response var byte
    sentcommand var byte

    flagbag var byte
    point var byte


    ' ** Declare the Constants **
    B1200 CON 17197 ' Inverted 1200 baud for SERIN2
    B2400 CON 16780 ' Inverted 2400 baud for SERIN2
    B4800 CON 16572 ' Inverted 4800 baud for SERIN2


    'Set variable values

    x = 0
    i = 0
    j = 0
    k = 0

    goto endsub

    endsub:

    ADCON0.0 = 0
    ADCON1 = %11001111

    CMCON = 7
    CVRCON = 0
    LVDCON = 0


    'set pins for input/output


    TRISA = %00000000 'RA0 = SDA
    'RA1 = SCL
    'RA2 = LED BackLIght RED
    'RA3 = Receiver 3 volt power
    'RA4 = LANC
    'RA5 = Transmit/Receive Select
    'RA6 = CRX
    'RA7 = CRX

    TRISB = %00000011 'RB0 = touch interrupt
    'RB1 = RF In
    'RB2 = R/W
    'RB3 = shutdown of I/O translation/
    'RB4 = D/I CD
    'RB5 = Serial Out Debug
    'RB6 = ICSP
    'RB7 = ICSP

    TRISC = %00011000 'RC0 = /CS1
    'RC1 = /CS2
    'RC2 = /RST
    'RC3 = I2C SCL Hardware
    'RC4 = I2C SDA Hardware
    'RC5 = LED
    'RC6 = E
    'RC7 = LED Backlight Green

    TRISD = %00000000 'RD0 = DATA to GLCD
    'RD1 =
    'RD2 =
    'RD3 =
    'RD4 =
    'RD5 =
    'RD6 =
    'RD7 =

    TRISE = %00000011 'RE0 = Analog Input/Power supply
    'RE1 = Analog Input/RSSI
    'RE2 = led bACKLIGHT BLUE
    'RE3 = MCLR
    'RE4 = N/A
    'RE5 = N/A
    'RE6 = N/A
    'RE7 = N/A

    low T_R 'receive mode before power down
    low shutdown
    low RFpower

    high LED
    pause 200
    low LED

    low blue
    high green
    low red

    debug "Power Up",13,10


    for address = 0 to 235

    debug dec address,13,10
    pause 10
    next

    dat = 0
    cd = 0
    rw = 0
    e = 0
    cs1 = 0
    cs2 = 0
    rst = 1

    pause 100

    rst = 0
    pause 10
    rst = 1
    pause 500


    mainloop:

    'ON INTERRUPT GoTo myint ' Define interrupt handler


    main:
    high LED
    pause 200
    low LED
    pause 200

    goto main



    ' Interrupt handler
    Disable ' No interrupts past this point

    myint:

    ' Clear interrupt flag
    Resume ' Return to main program
    Enable


    end

  2. #2
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default Re: debug issue?

    I am not sure if it defaults to on, so it may not help. But to compare your config settings to default, you have not turned your:
    Code:
    __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


    MeLabs turns it off for all devices.

  3. #3
    Join Date
    Jun 2004
    Posts
    18


    Did you find this post helpful? Yes | No

    Default Re: debug issue?

    Thank you! Thank you!

    What does that exactly do?
    I read the fuse description but don't know for sure why it worked.

  4. #4
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default Re: debug issue?

    Quote Originally Posted by Brian View Post
    What does that exactly do?
    Good question! I know it turns off an extended assembly instruction set that PBP can't use. But why it makes the chip work erratically, I don't know.

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