CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

LCD HD44780 PCF8574T i2c Driver
Goto page Previous  1, 2, 3, 4, 5, 6  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
i26c2



Joined: 01 Apr 2015
Posts: 19

View user's profile Send private message

PostPosted: Thu Apr 02, 2015 10:50 am     Reply with quote

So I have added a level translator and I now have 5V on my display and my i2C is being pulled up on both sides of the level translator (resistors are part of the translator). I just connected and ran the code and used a logic analyzer and nothing appeared on the output pins of the PIC
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Thu Apr 02, 2015 11:36 am     Reply with quote

What level translator?. You do realise that you can't use a conventional 'level translator' IC. You need an I2C translator, like the PCA9306. Look at AN10441 from national (NXP).
i26c2



Joined: 01 Apr 2015
Posts: 19

View user's profile Send private message

PostPosted: Thu Apr 02, 2015 11:58 am     Reply with quote

The level translator I am using was used by others for i2C before: https://www.sparkfun.com/products/12009. Even if that component is not working, the PIC should still output the data to the pin though.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Apr 02, 2015 1:22 pm     Reply with quote

Run this program on your PIC and find out what i2c slave address it reports:
http://www.ccsinfo.com/forum/viewtopic.php?t=49713
i26c2



Joined: 01 Apr 2015
Posts: 19

View user's profile Send private message

PostPosted: Thu Apr 02, 2015 2:32 pm     Reply with quote

I can't do anything with printf, I don't think I have enough pins left to use a serial connection. In any case, I think the issue might be the level translator and/or LCD. I removed the translator and pulled up to 3.3V through a 5.1k resistor and it appears on my logic analyzer just fine, as soon as I attach the level translator and LCD, it stops working, no data or clock, even with the additional pull up in place. Maybe I need to put additional pull ups on the other side of the translator as well. If that doesn't work I am out of ideas, lol.
temtronic



Joined: 01 Jul 2010
Posts: 9243
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Apr 02, 2015 4:46 pm     Reply with quote

You should post a schematic of your project for us. It's dificult to understand how you can't have ONE pin available for serial output to PC when you've got a 40 pin device and 2 pins are used for I2C!

Jay
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Apr 02, 2015 4:54 pm     Reply with quote

Quote:
I can't do anything with printf, I don't think I have enough pins left to use a serial connection

All you need is one pin. Do you have the CCS IDE with their ICD-U40
or ICD-U64 debugger/programmer ? If so, it has a built-in software
UART output from the PIC that is displayed in the IDE. It's called the
monitor.
i26c2



Joined: 01 Apr 2015
Posts: 19

View user's profile Send private message

PostPosted: Fri Apr 03, 2015 10:52 am     Reply with quote

I am using the icd-u64 with 3 pins, clock, data, and mclr connected. My project is a sun following solar powered cell phone charger with internal battery. I want to implement data logging of the charging rate of the internal battery and display that rate on the LCD when a push button is pressed. Pretty much everything is implemented aside from the LCD and charging indicator, both of which use i2C thankfully, because the sensors and motors and programmer take almost all the pins on the device. 20 pins goes really fast in a large project.

Anyway, if I can get printf to work without using any additional pins please let me know. I have never used PIC before so I have no idea how to set that up.

I have determined that the issue has to be either with the level translator or the LCD, because without them plugged if I pull up to 3V I get i2c waveforms on the clock and data pins (checked using logic analyser). As soon as I plug in to the level translator (which is connected to the LCD) no more waveforms outputted from the PIC. As for address the documentation for the LCD i2C module clearly states that if all 3 jumpers are in place, which they are, the address is 0x20, which is what I am using in the code.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Apr 03, 2015 11:16 am     Reply with quote

Is the address really 0x20 ? The sample code for this lcd is Arduino.
Arduino uses the 7-bit format i2c address. But CCS uses 8-bit format.
That's why I wanted you to run the i2c bus scanner program. But since
you can't do that, try setting the i2c address to 0x40. That's in 8-bit
format. See if that works.
i26c2



Joined: 01 Apr 2015
Posts: 19

View user's profile Send private message

PostPosted: Fri Apr 03, 2015 6:47 pm     Reply with quote

So I changed to 0x40. I was getting some data but I also noticed that I was getting only 1.5V max on both Input and Output of level translator. I then realized I never grounded my logic analyzer. If I attach the ground on my analyzer I cannot get it to trigger. If I don't connect the ground it will trigger but usually is just random noise. Ocasionally I will get what looks like some data, but it maxes at 1.5V. I am not sure if this is my circuit, or if it is because I am not grounding the analyzer, but when I ground the analyzer it will not trigger at all. I am starting to wonder if my I2C pins on my PIC are not working correctly.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Apr 03, 2015 6:58 pm     Reply with quote

Post a schematic of your whole circuit.

How to post an image on the CCS forum:
Go to this website: http://postimage.org/
Upload your image. Select family safe. Then click the first button for
"Hotlink to Forum" to get a link to the image.
Then go to the CCS forum and type Ctrl-V to paste the link into a post.

If postimage.org doesn't work in your country, then use Google to find
another free image hosting site for forums.
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Sat Apr 04, 2015 12:28 am     Reply with quote

i26c2 wrote:
I am using the icd-u64 with 3 pins, clock, data, and mclr connected. My project is a sun following solar powered cell phone charger with internal battery. I want to implement data logging of the charging rate of the internal battery and display that rate on the LCD when a push button is pressed. Pretty much everything is implemented aside from the LCD and charging indicator, both of which use i2C thankfully, because the sensors and motors and programmer take almost all the pins on the device. 20 pins goes really fast in a large project.

Anyway, if I can get printf to work without using any additional pins please let me know. I have never used PIC before so I have no idea how to set that up.

I have determined that the issue has to be either with the level translator or the LCD, because without them plugged if I pull up to 3V I get i2c waveforms on the clock and data pins (checked using logic analyser). As soon as I plug in to the level translator (which is connected to the LCD) no more waveforms outputted from the PIC. As for address the documentation for the LCD i2C module clearly states that if all 3 jumpers are in place, which they are, the address is 0x20, which is what I am using in the code.


As a first comment, consider if you can _temporarily_ get access to another pin?. I had a board with all pins used, but one interface was RS485 on it. This needed a direction control line. For debugging, I turned off the direction control, switched to using RS232 for this interface, and then used the extra pin this released for the debug output. Is there some peripheral you could 'run without', till you get the LCD working?. Do you (for instance) even have something like an LED driven from the PIC?. If so, you could debug, by just adding a routine to flash this, and adapt PCM_programmer's code to flash this to give the detected address. If you are driving motors, then disconnect these, and use the pins for debugging, until you have the LCD working. This is the first rule of debugging 'divide and conquer'....

Then what signal level are you seeing on the PIC I2C pins with the voltage translator added?. High, Low?. If the signal is sitting low, then the pull-ups on the translator are not working.
I2C, is an open collector bus. The devices only ever pull the signals low, and are dependant on the external hardware to pull them high (normally the pull up resistors). If the signals are low, then something is wrong with the pull ups.
i26c2



Joined: 01 Apr 2015
Posts: 19

View user's profile Send private message

PostPosted: Sat Apr 04, 2015 9:48 am     Reply with quote

I rebuilt just the LCD portion of the system on a breadboard with a spare pic and level translator, and I have come to the conclusion that the level translator is the problem. I tried the following configurations:

Just the PIC straight to the logic analyzer with 5.1k pull-ups: This gives me clean 3V i2C data as it should

PIC connected to the level translator, pull-ups in place: clean data on input, output data looks garbled and also only goes to 3V

PIC connected to level translator, input pics in place, added output pull-ups to 5V: same

PIC connected to level translator, no pull-ups on either side: Will not trigger

I think its clear the issue is the level translator, it is not correctly outputting the 5V. Maybe the 10K resistors that are inside are leading to a terrible RC time constant and it just never pulls up all the way, or maybe there is some other problem, but the translator has to be the issue. I don't know if I can get another translator in time. Could I build one out of transistors?
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Sat Apr 04, 2015 10:46 am     Reply with quote

Look at the application note I pointed to earlier. Two small mosfet's, does it properly. Make sure you note that the 3.3v is on the left in the circuit given, and that the resistor values will need to suit your bus capacitance and voltage. Possibly perhaps 1 to 2KR on the 3.3v side, and a bit higher on the 5v side.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Apr 04, 2015 11:15 am     Reply with quote

You have never posted a schematic. Do you have 3.3v, 5v, and ground
connected to the center pins on the Sparkfun level converter board ?
See this diagram:
https://cdn.sparkfun.com/assets/e/2/8/f/f/advanced-redboard_levelShift_bb.png
Look at the Sparkfun level converter board.

1. The red wire connects +5v to the HV pin on the board.
2. The black wire connects ground to the upper ground pin on the board.
3. The red/white wire connects +3.3v to the LV pin.
4. The black wire next to it connects ground to the lower ground pin.

Do you have all these connections ? If you have the connections, can
you use a scope or a meter to check if the voltages are there, and are
correct. Can you also verify the ground connections with an ohmmeter
(when the power is off).
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2, 3, 4, 5, 6  Next
Page 3 of 6

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group