Announcement

Collapse
No announcement yet.

No RS232 ICD comms to Pic18F4680

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • No RS232 ICD comms to Pic18F4680

    I am trying to get MicroCo Studio Plus (ver 5.0.0.5) IDE to work. I get the error message "Microcode Studio was unable to connect to the {PIC....."

    Background:
    My overall project is to use Pic Micro-controllers for various control functions on my model railway. These range from a simple traffic light controller through servo driven point motors up to an automated six track storage system.

    Given the problem trying to debug software when one can't view the program in progress, I decided to use the MicroCode Studio ICD function using an Pic 18F4680 as a surrogate. That is, loading the programs destined for lesser chips into the 4680 and reassigning the ports.

    Initially I tried this using a QL200 development board, but for various reasons (including no comms) I gave that up and constructed my own test board with switches and LEDs able to be connected to the Pic bins with jumper leads. USB to serial is by means of a Arduino compatible USB to Serial Adapter Module. plugged into the test board. (Circuit and PCB layout attached )
    The first attempt was a controller for a set of Green/Amber/Red traffic lights destined for a Pic 12F510. The program is simple and seems ideal to a first test as the program just cycles round and round and needs no external inputs,

    When that failed to run I dropped to an even simpler program that just flashes a single LED. This program has configuration settings according to my reading of the Pic 18F4680 data sheet and the PIC18F4680.INFO file. I have (Attempted to?) set the oscillator option to 8 MHz internal with the clock output on RA6

    Test Results:
    The IDC compiled program is loaded to the 18F4680 using a PicKit 2. That process appears to be successful in that the program loads and verifies. Every time, every version described below.

    With the 18F4680 in the test board and powered up Microcode Studio recognises the USB/RS232 connection as Com10 in the drop down selection. I seems Microcode Studion can see the USB/RS232 board

    When I try to run the program under ICD control I get the "Can't communicate" message. I have followed all the (Limited ) suggestions provided by Micro Code, to no avail. Perhaps more important I get no output on RA6 (measured by logic analyser). And yes, the Pic does have 5v measured correctly on its power pins.

    I have repeated the process with an 18F4680 from another purchase batch, and with an 18F4550. All with the same result. I have repeated all the before step with standard compiling. I have repeated all the before with no config statements in the program, relying on the default programmer settings.

    Always the same result - no signs of life from the Pic. Hours of research on this and other sites have not yielded me a solution.

    I have not tried a replacement USB/232 board, as I reason that since there is no response from and Pic in any form of the program, Pic life has to be established before working on the cms issue. It may well be that getting the Pic to burst into life will also blow life into the CD comms function.


    Conclusions:
    My (inexpert) conclusion is the most likely source of the problems are; first, I have incorrectly configured the Pic in some way that prevents it operating at all. Second I may also have, through misunderstanding/ignorance, failed to set the RS232 settings for IDC communication - I made the assumption that the IDC compiling would handle that, ( the .ASM file content appears to confirm that.)

    Can anyone shed light on this please? There must be a simple solution, because everyone out there seems to be happily programming their Pics except me. But a reason for my failure has plumb evaded my many hours of effort thus far and is seriously holding up my string of projects.

    ATTACHMENTS
    PicBasic program
    Corresponding .ASM file
    Corresponding HEX file
    Test board circuit
    Test Board PCB

    Analyser file not included, as it just shows no output on RA6.
    Attached Files

  • #2
    the first thing I notice
    Code:
    ' Description : PICBASIC Program to Test set up by alternate flashing ports
    
    '
    ' Circuit     :
    
    ' Target PIC  : 18F4680
    '               Pogram 1048 words
    '               SRAM     38 bytes
    '
    ' Compiler    : PICBASIC PRO Compiler 2.6
    ' Assembler   : MPASM
    
    ' Oscillator  : Internal  8MHz
    
    ' ******************************************************************************
    ' Comments
    
    
    ' ******************************************************************************
    ' Initialise
    ' 18F4680 Debug
    #CONFIG
    CONFIG OSC = ECIO
        CONFIG FCMEN = OFF
        CONFIG IESO = OFF
        CONFIG PWRT = OFF
        CONFIG BOREN = OFF
        CONFIG WDT = OFF
        CONFIG MCLRE = OFF
      #ENDCONFIG
    
      DEFINE OSC 8

    config OSC
    does NOT match that comment,

    so what is it
    do you have an external 8mhz xtal ?
    or
    if you have not then the config needs to be fixed along with the matching appropriate setting for the osccon reg
    otherwise it will run at the default setting of 1mhz for that chip


    secondly did you create an appropriate ICD model for your chip and its OSC/Baud rate

    Comment


    • #3
      Richard, Thank you very much for the prompt reply.

      First, the easy bit. Yes I did create an ICD model for the chip. The settings in the .ASM file seem to indicte the RS232 settings match that of mt USN/RS232 board.

      I changed the Config statements thus:



      #CONFIG
      CONFIG OSC = IRCIO67 ' Clk out on RA6, IO on RA7 NOTE All internal oscillator statements fail to compile.
      CONFIG FCMEN = OFF
      CONFIG IESO = OFF
      CONFIG PWRT = OFF
      CONFIG BOREN = OFF
      CONFIG WDT = OFF
      CONFIG MCLRE = OFF
      #ENDCONFIG

      ' Set oscillator to 8 MHz
      OSCCON.4 = 1
      OSCCON.5 = 1
      OSCCON.6 = 1

      OSCCON.1 = 1
      OSCCON.0 = 0

      DEFINE OSC 8


      The program now will not compile as it will not recognize IRCIO67 or the other internal oscillator setting. Perhaps this has been my problem all along - no recognised internal oscillator setting and no connected external oscillator. I did think of trying to write the appropriate bits directly into CONFG1H, and spent hours since my first post trying to find how to do that or any correction to the internal oscillator config statements for this chip. To no avail.

      So, can you suggest anything the activate the internal oscillator? That is, is there an amendment to IRCIO67 etc, is there a method to write the bits for CONFIG1H as described in the datasheet directly or whatever else.

      Thanks again.

      Comment


      • #4
        you cannot place comments that way in a #CONFIG block it is a syntax error

        also when you supply a partial list of config settings all those not mentioned revert to the blank chip defaults which can lead to confusion

        if you alter the config from pbp default then look at the device inc file and provide a complete #config block for best results
        eg

        #CONFIG
        CONFIG OSC = IRCIO67
        CONFIG FCMEN = OFF
        CONFIG IESO = OFF
        CONFIG PWRT = OFF
        CONFIG BOREN = BOHW
        CONFIG BORV = 3
        CONFIG WDT = ON
        CONFIG WDTPS = 512
        CONFIG PBADEN = OFF
        CONFIG LPT1OSC = OFF
        CONFIG MCLRE = ON
        CONFIG STVREN = ON
        CONFIG LVP = OFF
        CONFIG BBSIZ = 1024
        CONFIG XINST = OFF
        CONFIG DEBUG = OFF
        CONFIG CP0 = OFF
        CONFIG CP1 = OFF
        CONFIG CP2 = OFF
        CONFIG CP3 = OFF
        CONFIG CPB = OFF
        CONFIG CPD = OFF
        CONFIG WRT0 = OFF
        CONFIG WRT1 = OFF
        CONFIG WRT2 = OFF
        CONFIG WRT3 = OFF
        CONFIG WRTC = OFF
        CONFIG WRTB = OFF
        CONFIG WRTD = OFF
        CONFIG EBTR0 = OFF
        CONFIG EBTR1 = OFF
        CONFIG EBTR2 = OFF
        CONFIG EBTR3 = OFF
        CONFIG EBTRB = OFF
        #ENDCONFIG

        Comment


        • #5
          also , forget about icd get a led to blink @ the correct rate first , small steps

          Comment


          • #6
            Thanks Richard.

            Followed advice, concentrated on a non-IDC version and set all the CONFIG statements from the 18F1680.INFO file as suggested. And, I removed the comment in the CONFIG section of the programs, as it was indeed this comment that was causing the compile error. The new program and ASM files are attached


            The program now compiles and verifies. But when run, there is no sign of life - No blinking LED, no clock output on RA6 according to the analyser. The analyser only records (correctly) the application and removal of power to the chip. No sign of life on any other pin.

            Any suggestions for my next step please?
            Attached Files

            Comment


            • #7
              the pin you have chosen for the led has analog capability , by default pic pins that have analog functionality cannot be used as digital until the pin has been set to digital
              the pin you have chosen for the led has not been set as output .


              Comment


              • #8
                there is no need to attach the asm file . and it make life easier if you post your code in code tags [the # option in advance mode / read the faq on how to use forum


                http://support.melabs.com/forum/me-l...sked-questions

                Comment


                • #9
                  Richard,

                  Thanks again for your prompt help.

                  Setting an analog capable pin to output was so simple it evaded me. I learned from you what I think is an important lesson. In all matters associated with device configuration best to put values in code for all , and do not rely on the default values or PicBasic to do it automatically.

                  I take your point about how best to post code, and I had read the FAQ. But it days "Use the text editor and select A on the top right ...." You confirm that advice as above. But, what text editor does this refer to? I cannot find such an option in MicroCode Studio, not can I fins any other test editor related to the compiler or MPASM and so on Nor can I find a reference on the ME Lab site nor in the forum. Does not mean to say it is not there, just that I can;t find this after several hours of close and varied searching. Again, could you please assist with what must be the (invisible) obvious?

                  Comment


                  • #10
                    I cannot find such an option in MicroCode Studio, not can I fins any other test editor related to the compiler or MPASM and so on Nor can I find a reference on the ME Lab site nor in the forum. Does not mean to say it is not there, just that I can;t find this after several hours of close and varied searching. Again, could you please assist with what must be the (invisible) obvious?



                    its not in mcs, its how the forum works



                    as in FAQ



                    2. How do I post code so that it is readable for others?
                    The best way to post code is to use the text editor. In the upper right corner click on the "A" and a text editing bar appears. Then highlight the code you want formatted. Then click on the "#" and it will format the code so it has its own scroll bar and is easy to read. Another method is to use html tags. Simply paste in the code between these two tags "code" in square brackets ([ ]) and /code (also in square brackets) and when it appears in the forum posting it will be properly formatted.
                    Attached Files
                    Last edited by richard; 01-23-2018, 05:08 PM.

                    Comment

                    Working...
                    X