Does 16F628a support debugging or not?


Closed Thread
Results 1 to 19 of 19

Hybrid View

  1. #1
    Join Date
    Jun 2011
    Location
    Indian Harbour Nova Scotia
    Posts
    108


    Did you find this post helpful? Yes | No

    Default Re: Does 16F628a support debugging or not?

    I went back to the simplest circuit I could make with minimal programming just to test the ICD but I still can't get it to work. I have checked that when I send out a character to my Max232 chip that the signal gets level corrected and sent to the Rx pin of the 16F628a.
    When I "Compile Program" using MCS+ the LED (code below) blinks as required. When I "ICD Compile Program" the blinking stops, and I get a time-out error when I try to run the debugger.
    Using the serial communicator in MCS+, I can send out the character "h" but I get nothing returned. the Bytes TX count goes up by the number of characters I send out and curiously (because I don't know the cause), the Bytes RX count continuously increments rapidly to 16000+ and doesn't quit until I

    Question: Is there anything else I have to do to get the ICD working? (perhaps a config word or register setting?)
    Question: What data am I receiving (RX of 16000+)
    Question: Why does execution stop (ie LED stops blinking) when I "ICD CompileProgram"?

    Program is here:
    TRISA = %00000000 'ALL OUTPUTS
    TrisB = %00000010 'Rx on b.1, pin 7 and Tx on pin 8
    #config
    __config _INTRC_OSC_NOCLKOUT ; for 16F628
    #endconfig
    START:
    High PORTA.6 'ON LED
    Pause 1000
    Low PORTA.6 'OFF LED
    Pause 1000
    GoTo START 'REPEAT

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


    Did you find this post helpful? Yes | No

    Default Re: Does 16F628a support debugging or not?

    It sounds to me as if the PIC never starts up properly, the TX-pin on the PIC never becomes an output so it floats which probably makes the MAX232 output "the wrong" idle state on its output to the PC so the PC keeps "receiving" bytes. Try forcing the TX output on the PIC into the correct state with a resistor. I believe the correct idle state of the TX-line is high and because the MAX232 inverts the signal you should pull it low but I might have that the wrong way around.

    Now, this doesn't adress the real problem of WHY the PIC doesn't start up properly, have you measured or scoped the voltage on the MCLR-pin to verify that it's not kept in reset?

    /Henrik.

  3. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: Does 16F628a support debugging or not?

    Your __config line doesn't have enough options in it ...
    Code:
    #CONFIG
        __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_ON & _MCLRE_ON & _BOREN_OFF & _LVP_OFF & _CPD_OFF & _CP_OFF
    #ENDCONFIG
    When using #CONFIG/#ENDCONFIG, ALL defaults are overridden and you must supply ALL config options.
    The way it was would have left LVP ON.

    This program with a 16F628A in an melabs LAB-X3 board, works fine with the ICD.
    Code:
    #CONFIG
        __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_ON & _MCLRE_ON & _BOREN_OFF & _LVP_OFF & _CPD_OFF & _CP_OFF
    #ENDCONFIG
    
    DEFINE OSC 4
    
    LED1  VAR PORTB.4
    CMCON = 7
    
    Main:
        HIGH LED1
        PAUSE 500
        LOW LED1
        PAUSE 500
    GOTO Main
    But the ICD will never work if RS232 comms are not working.
    Here's a simple LoopBack program. Compile it with the normal "Compile Program" button.
    Use Serial Communicator at 19200, and whatever you send should be returned.
    Once you get that working (strictly a hardware issue), the ICD will work.
    Code:
    #CONFIG
        __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_ON & _MCLRE_ON & _BOREN_OFF & _LVP_OFF & _CPD_OFF & _CP_OFF
    #ENDCONFIG
    
    DEFINE OSC 4
    
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
    DEFINE HSER_SPBRG 12  ' 19200 Baud @ 4MHz, 0.16%
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    
    Char  VAR BYTE
    
    CMCON = 7
    
    Main:
        HSERIN [Char]
        HSEROUT [Char]
    GOTO Main
    DT

  4. #4
    Join Date
    Jun 2011
    Location
    Indian Harbour Nova Scotia
    Posts
    108


    Did you find this post helpful? Yes | No

    Default Re: Does 16F628a support debugging or not?

    First I did as Henrik suggested, trying to pull down the Tx line (100 ohms, didn't work). The MCLR is high, not reset.

    Then I changed the Config statement per Dave, in my own program. Didn't change anything: LED blinks when normal compile, but won't blink on ICD compile.

    So I ran Dave's program but my PortA.7 (since LED was there). His had CMCon=7, otherwise program is the same. Got same results. So I used EXACTLY Dave's program ie PortB.4 and still the same results.

    Bottom line: program works when I normal compile, doesn't work when I ICD compile.

    NOTE: the RS232 lines were NOT connected whatsoever, the power for my breadboarded circuit (the 16F628a) is from the LABX-1 to make sure it's clean power, and the CONFIG statement Dave provided cannot have the CPD_OFF fuse because it doesn't exist in a 16F628A.INC file. The program won't compile with CPD_OFF in the string.

    I noted that an ICD compile REALLY adds a LOT of overhead to the ASM file. Could this extra code be trashing memory?

    I don't understand how your program can work on a 16F628a whereas mine won't even compile. I tried a DIFFERENT chip and get the same results.

    I haven't done the loopback yet for obvious reasons.

  5. #5
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Dave's not here maaann.

    What version of PBP3 do you have?
    The current version is 3.0.5.x
    http://pbp3.com/download.html

    What version of MPLAB do you have?
    Current version - 8.85
    The latest PBP3 will install MPLAB 8.84
    DT

  6. #6
    Join Date
    Jun 2011
    Location
    Indian Harbour Nova Scotia
    Posts
    108


    Did you find this post helpful? Yes | No

    Default Re: Does 16F628a support debugging or not?

    Sorry Darrel...I know another guy named Dave Taylor.
    I have MCS 5.0.0.3
    PBPX 3.0.1.4
    MPLAB 8.73

    Since I'm grasping at straws here, I will do all the updates.

    BTW, Ran the serial test program you sent me. No matter what character I send out, I get a weird character back, like it's a baud rate problem. I changed baud rates in software to 9600 and the serial comm to same but it still gives same results. I tried even lower rates, no different. My PC serial card was set for 9600 baud, changed it to 19200 and the program and communicator to same. Same results. Type h, get back an "e" with back slanting accent.

  7. #7
    Join Date
    Jun 2011
    Location
    Indian Harbour Nova Scotia
    Posts
    108


    Did you find this post helpful? Yes | No

    Default Re: Does 16F628a support debugging or not?

    Darrel, I upgraded MPLAB, MCS+ and PBP3.0 as required. No change.
    However, I changed power supply to my circuit, the 16F628a and MAX232 chip. Instead of using the limited power supply of the LabX1, I used my other supply, a switching walwart supply. NOW my serial communicator works first time everytime. Type an "h", get an "h".
    Obviously I was stressing the LabX1 supply and must have caused it to clip or get noisy.

    Still have the compile ICD that doesn't work.

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