LCD interfering with ICSP?

Discussion in 'Embedded Systems and Microcontrollers' started by tracecom, Jan 5, 2014.

  1. tracecom

    Thread Starter AAC Fanatic!

    Apr 16, 2010
    3,869
    1,393
    Suddenly, I am unable to program the attached circuit with my PICKit2 unless I disconnect (unplug) the LCD. I get a "device not detected" message. Meanwhile the circuit works well. Why could this be and what can I try to correct it? Thanks.
     
  2. JohnInTX

    Moderator

    Jun 26, 2012
    2,340
    1,022
    You may need to isolate RB6/7 from the LCD with series resistors. It could be that the LCD is adding load (resistive or capacitive) that is fouling the ICSP. Why it happens now might indicate that you were on the edge before. The various ICSP references always show some kind of isolation from the rest of the circuit when the port lines are shared.

    It wouldn't be a bad idea to pull the LCD E line down as well. During reset and programming this line may float high and foul the DB lines.

    Don't forget to disable LVP in the config word.

    Good luck!
     
    tracecom likes this.
  3. tracecom

    Thread Starter AAC Fanatic!

    Apr 16, 2010
    3,869
    1,393
    John,

    You are a fount of good info. I decided to try the easy solution first, and put a 10k from the LCD E lead to ground. Instant success. Thanks.

    ETA: Oops. I spoke too quickly; it worked once, but then failed. I'll try your other suggestions.
     
  4. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    You could try to "isolate" pin 12 and 13 (ICSPDAT ICSPCLK) from the LCD with some resistors. Around 470 to 1K should work fine. Place the isolation resistors as close as you can to the chip
    http://forum.allaboutcircuits.com/attachment.php?attachmentid=63175&d=1388795503
     
    tracecom likes this.
  5. tracecom

    Thread Starter AAC Fanatic!

    Apr 16, 2010
    3,869
    1,393
    Apparently, there are lots of potential causes for this problem. While searching for a value for the LCD series resistors, I found a suggestion that unused LCD leads should be grounded. I grounded DB0-DB3, and the problem is gone.

    However, I think I will add some series resistors in the DB4-DB7 leads. What value is appropriate for those? 33Ω was suggested somewhere I think.

    I also will add the 470Ω to 1kΩ series resistors in the PGD and PGC leads as suggested by TO6.

    Thanks.
     
  6. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,866
    988
    I have never added series resistors on the db lines. I have always connected them direct and never had an issue but I have not built a ton of LCD projects either.

    I also try to never use PCG and PCD as ports. It is a heck of a lot easier to not to have to mess with it especially when it comes to debugging.

    You have RA6 and RA7. Why not just use them instead and eliminate the issue altogether?

    BTW this thread probably belongs in the embedded forum.
     
  7. tracecom

    Thread Starter AAC Fanatic!

    Apr 16, 2010
    3,869
    1,393
    If I understand correctly, all the LCD control lines have to be located either in the top half (0-3) or the bottom half (4-7) of one port. So, I would have to relocate quite a lot of connections to allow that. However, I may do so because this is really just a test circuit anyway. Grounding the unused LCD inputs seems to have resolved the issue I was having. Thanks for the input.
     
  8. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    Or get a bigger hammer(controller with more pins);) The price for this upgrade is quite small. If you just are a hobbyist.
     
  9. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,866
    988
    There is no need to place all of the data and control pins on the same port. It makes it slightly easier to program but there are plenty of libraries out there that allow you to define your individual data and control pins.
     
  10. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    The data pins may change in a asynchronous manner. As long as they are stable then LCD E pin toggle high/low
     
  11. tracecom

    Thread Starter AAC Fanatic!

    Apr 16, 2010
    3,869
    1,393
    I will look into that; I think it may be a PicBasic requirement, which is what I am writing code in.
     
  12. MMcLaren

    Well-Known Member

    Feb 14, 2010
    759
    116
    LCD connection requirements are part of the PBP LCD driver/function. If you write your own driver you could connect the LCD to any pins you want but you'd lose that nice DEC parameter capability.

    BTW #1: You could use my little Serial LCD Backpack design (below), which would only require a single I/O pin, by simply replacing each LCDOUT instruction in your program with the serial DEBUG instruction (using same instruction parameters).

    BTW #2: There is an FVR (fixed voltage reference) module in many of the new "enhanced mid-range" devices which can provide a 4.096 volt reference to the ADC module (without using an I/O pin).

    You could connect two pots and a serial LCD backpack onto an eight pin 12F1822 and duplicate the functionality of your current 16F88 circuit, with pins left over (grin).

    Regards, Mike
     
  13. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,866
    988
    Am I missing something? I see 5 I/O pins being used. What are the programming requirements? Set D4 last?
     
  14. MMcLaren

    Well-Known Member

    Feb 14, 2010
    759
    116
    The D4 pin is used to charge or discharge the capacitor on the RS pin for several microseconds before writing each nibble to the LCD. The D4 through D0 lines are setup immediately before pulsing the E line as you write each nibble to the LCD. Please let me know if you'd like more details.

    Cheerful regards, Mike

    [​IMG]
     
  15. tracecom

    Thread Starter AAC Fanatic!

    Apr 16, 2010
    3,869
    1,393
    Even after grounding the unused LCD pins, I still had problems with the PICkit2 not seeing the PIC. I ended up adding a 1k series resistor in each of the four LCD signal leads, which (once again) seems to have resolved the issue, but I have thought that at least twice before. Time will tell.

    When I go through this again, I will think through which PIC pins to use for the LCD, and will avoid the programming pins. This whole exercise was for experimenting and learning, and I feel like I have done that.

    I am aware that some PICs have an internal precision voltage reference, but I haven't looked to see if the 16F88 has one or not. If it does, I will certainly try it.

    With regard to a serial interface, I actually have three backpacks: two from Modern Devices and one from Wolfden. The code for all three was written by the late Peter Anderson. However, I would be very interesting in building one using the 12F635. Do you supply the code, Mike?

    Thanks.
     
  16. MMcLaren

    Well-Known Member

    Feb 14, 2010
    759
    116
    Here's the source code and hex file for a 12F683 version. The source would need minor changes if you want to use a 12F635 or a 12F1822...

    The backpack initializes the LCD on power up so you should allow approximately 50 milliseconds after power up on your host system before sending serial data to the LCD. This version uses the 0xFE character as a prefix for any LCD control characters (RS = 0), just like the LCDOUT function in PBP. Default speed is 57600 baud but that can be changed in the source code and re-assembled.

    Please let me know if you need any help...

    Cheerful regards, Mike
     
  17. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,866
    988
    One option would be to place jumpers. But you would need to remember to switch between "program" and "run" mode at the appropriate times.

    I could not any documentation for Pic Basic LCD.

    I did find this blog

    http://rasduet.blogspot.com/2013/03/lcd-interfacing.html

    I find it awfully strange that you would define each of the control pins but not each of the data pins so you might be right about it being a requirement of the library. It looks like you define the first pin of the port that is to be used for data. A very poor requirement for a library IMHO. I would hope there are other options that are just not being shown.

    BTW in the blog, he uses PGC and PGD. No resistors or anything. Are you certain your connections to the ICSP are solid? Can you show your ICSP connections? It very well could be he does not use inline programming.
     
  18. tracecom

    Thread Starter AAC Fanatic!

    Apr 16, 2010
    3,869
    1,393
    My setup is shown in post #9 of this thread. http://forum.allaboutcircuits.com/showthread.php?t=93064 In that photo, I had not yet added the series resistors.

    It could be capacitance introduced by the solderless breadboard.


    ETA: The code to run the LCD is partially shown in the last post in that same thread.
     
  19. tracecom

    Thread Starter AAC Fanatic!

    Apr 16, 2010
    3,869
    1,393
    Thanks. No, I would prefer a 12F683; I just saw the 12F635 on your drawing. I'll build it tomorrow. :)

    ETA: I just saw the source code is ASM, which I know nothing about. But maybe this is another learning opportunity.
     
  20. tracecom

    Thread Starter AAC Fanatic!

    Apr 16, 2010
    3,869
    1,393
    Mike,

    I downloaded the code and had a look at it, but as I previously posted, I know next to nothing about asm. Does your code have the provision for sending "standard" control characters to the LCD?

    Thanks.
     
Loading...