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

PICtail Plus I2C EEPROM with PIC24FJ64GA004 in Explorer 16

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
LFern



Joined: 16 Mar 2011
Posts: 19
Location: Melbourne, Australia

View user's profile Send private message

PICtail Plus I2C EEPROM with PIC24FJ64GA004 in Explorer 16
PostPosted: Thu Jun 16, 2011 1:22 am     Reply with quote

Hi Guys,
I am trying to interface Memory PICtail plus I2C module which is having a 24AA512 EEPROM with the PIC24FJ64GA004 PIM in an Explorer 16 board.

I am using the 24512.c I2C EEPROM driver which comes with CCS compiler PCD 4.119V.

I don't be able to read any values out as it always gives me 0xff. I am wondering where is the exact problem.

I have connected the Memory PICtail correctly to the J5 of the Explorer 16 board.

Following is the test code:

main.c
Code:

#include <24FJ64GA004.h>
#fuses HS,NOWDT,FRC,NOWRT,NOPROTECT
#use delay(internal=8Mhz)   

#pin_select U2TX = PIN_C9                
#pin_select U2RX = PIN_C3               

#use rs232(UART2, baud=38400, stream=ABC)

#include <24512.c>

void main()
{
   BYTE val=0;
   output_high(PIN_B9);

   init_ext_eeprom();
   
   fprintf(ABC, "write to addr: 0x00 data: 0x01\n\r");

   write_ext_eeprom(0x00, 0x00);
   val = read_ext_eeprom(0x00);

   fprintf(ABC, "read addr 0x00: should be data: 0x01 and received: %x\n\r", val);
   
   while(1);
   
}


I have changed the #use i2c as follows in the driver: but no luck

#use i2c(master, i2c2)
LFern



Joined: 16 Mar 2011
Posts: 19
Location: Melbourne, Australia

View user's profile Send private message

PostPosted: Thu Jun 16, 2011 1:24 am     Reply with quote

Further, I have probe the scope in to SDA and SCL pins and I can see a change of signal when I do a loop of read/write.

But I am not getting correct reads out.

Your comments very much appreciate.
Ttelmah



Joined: 11 Mar 2010
Posts: 19496

View user's profile Send private message

PostPosted: Thu Jun 16, 2011 1:56 am     Reply with quote

Obvious thing for '0xff' returned, is the address not being right.
Remember the chip has eight possible addresses, according to the bit pattern on the A0 to A2 pins. You need to check how these are wired on the board, and change the address used in the code to match.
Pcm Programmer, published a little program at:

<http://www.ccsinfo.com/forum/viewtopic.php?t=42368&start=4>

which will scan the I2C bus, and tell you what addresses it finds devices on.

Best Wishes
LFern



Joined: 16 Mar 2011
Posts: 19
Location: Melbourne, Australia

View user's profile Send private message

PostPosted: Thu Jun 16, 2011 6:03 pm     Reply with quote

Thanks Ttelmah for your reply. I checked and confirmed that the I2C slave address of the EEPROM is 0 (A0-A2 pins grounded).

I have also tried out the reference program from PCM Programmer with below changes:
Code:

#include <24FJ64GA004.h>
#fuses HS,NOWDT,FRC,NOWRT,NOPROTECT
#use delay(internal=8Mhz)   

#pin_select U2TX = PIN_C9
#pin_select U2RX = PIN_C3
#use rs232(UART2, baud=38400, stream=ABC)

#ifndef EEPROM_SDA
#define EEPROM_SDA  PIN_B2
#define EEPROM_SCL  PIN_B3
#endif
#use i2c(master, sda=EEPROM_SDA, scl=EEPROM_SCL)


Interesting thing is that programs gives "ACK addr: nn" where 0x10<nn<0xF0. No matter whether I have plugged in the PICtail I2C module or not!

I am wondering is there any other setting is required in the Explorer 16 board to get PICtail I2C run.

This is the link to the PICtail I2C module:http://ww1.microchip.com/downloads/en/DeviceDoc/22128A.pdf

If someone used the PICtail I2C appreciate your comments.
temtronic



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

View user's profile Send private message

PostPosted: Thu Jun 16, 2011 8:01 pm     Reply with quote

Another obvious comment.

Do you have the correct pullup resistors for the I2C lines ? Perhaps they're a jumper 'option' to enable them on the daughter board or does the main PIC board have them ? Maybe both ?
LFern



Joined: 16 Mar 2011
Posts: 19
Location: Melbourne, Australia

View user's profile Send private message

PostPosted: Thu Jun 16, 2011 8:40 pm     Reply with quote

Hi temtronic,

Pullup resistors are there in the PICtail board itself. This is just a plug and play EEPROM board which almost all the hardware is done by Microchip.

If you go through the given datasheet of the PICtail eeprom board, you can see those pull ups.

There's no need to 'enable' them.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Fri Jun 17, 2011 3:29 am     Reply with quote

Quote:
Interesting thing is that programs gives "ACK addr: nn" where 0x10<nn<0xF0. No matter whether I have plugged in the PICtail I2C module or not!

Getting ACK without the PICTail board isn't surprizing, because the pull-ups are missing. But it shouldn't happen with the board plugged in. Did you check the SDA and SCL idle levels?

I don't see a problem from the Explorer 16 schematic, but it's not very clear, you can easily overlook a conflicting connection.

Unfortunately, I neither have the 24FJ64 PIM nor the I2C PICTail to reproduce the problem.
Ttelmah



Joined: 11 Mar 2010
Posts: 19496

View user's profile Send private message

PostPosted: Fri Jun 17, 2011 7:15 am     Reply with quote

Some comments:

First, I think you need a #PIN SELECT for the I2C PINS, to set them to the ones used by the explorer. All chips with re-mappable pins, must have select commands to tell the compiler which ones to use.

Then, you are putting the board into the second part of J5?. The first 30 pins, have the connection made to I2C1. It is pins 33 to 62, which use I2C2.


Best Wishes
LFern



Joined: 16 Mar 2011
Posts: 19
Location: Melbourne, Australia

View user's profile Send private message

PostPosted: Fri Jun 17, 2011 8:56 am     Reply with quote

According to PIC24FJ64GA004 datasheet, I don't need to do a #pin select since I am using i2c 2 port and it is hardware fixed.

I can do a #use i2c(master, i2c2) instead, but no luck.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Fri Jun 17, 2011 10:26 am     Reply with quote

I agree, that according to the documents the PICTail I2C terminals are connected to second 24FJ64 I2C Interface. And yes, the I2C interface is using fixed pins. As far as I understand, the peripheral pinselect technique doesn't work for bidirectional pins.
Ttelmah



Joined: 11 Mar 2010
Posts: 19496

View user's profile Send private message

PostPosted: Fri Jun 17, 2011 2:58 pm     Reply with quote

I still repeat my question about the fitting in J5 though.

The point is that J5, offers two different locations you can put the PicTail unit. the first location maps to I2C1, not I2C2. It is the second location that maps to I2C2. Pin 23 of the processor pin, maps to the 100pin connector SDA2, which goes to pin40 on J5. Similarly Pin 24 of the processor maps to the 100pin SCL2, and this goes to pin 38 on J5. The module _must_ be in the second slot on J5, to work with I2C2.

Best Wishes
LFern



Joined: 16 Mar 2011
Posts: 19
Location: Melbourne, Australia

View user's profile Send private message

PostPosted: Fri Jun 17, 2011 6:48 pm     Reply with quote

This Memory PICtail meant to use with J5 I2C1 pins. If you carefully cross refer following manuals you can get the idea.

1. Page 2 of http://ww1.microchip.com/downloads/en/DeviceDoc/22128A.pdf

2. Page 36 of http://spacegrant.colorado.edu/COSGC_Projects/co3sat/downloads/CS1-CDH709-00%20Explorer%2016%20Dev.%20Board%20User%27s%20Guide.pdf

3. Page 3 of http://ww1.microchip.com/downloads/en/DeviceDoc/PIM_24Fj64ga004_51663a.pdf


This is why I initiate I2C2 hardware port of micro.

Any comments?
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sat Jun 18, 2011 3:45 am     Reply with quote

As previously told, I agree with LFern about the I2C connection. But I would validate it's operation, e.g. with an oscilloscope connected to the SDA and SCL testpoints of the PICTail.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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