- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am trying to interface i2c EEPROM and RTC (24LC512 from Microchip and DS1307) CY8C28452,
i am using I2Cm module and configure P2_7 as SDA and P2_6 as SCL. also configure pin as OPEN DRAIN LOW and pull up the pins with 4K7 E resistor.
i use the source code provided in data sheet. but it not works. i check with CRO their is no pulsing on P2_7 as SDA and P2_6 as SCL. then i change pull up to 2k2 but still same thing.also i try with only RTC on board but no op my disply show me error.
i used system clk 24Mhz and CPU clk system clk / 2.
please help me
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi,
please find attachment for detail.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Do not use chrome when uploading any attachments, it will not work, use ie or firefox, they will.
Best would be when you attach the complete project, so we all can have a look at. Use Designer, File -> Archive Project and attach the resulting .zip archieve here.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The ports get set up for you, from datasheet -
- I2C_Port
-
Selects which PSoC I/O port is used to interface the SDA and SCL signals.
- SDA_Pin
-
Selects which pin of the I2C_Port, the SDA data signal will be present. There is no need to select the proper drive mode for this pin; PSoC Designer will do this automatically.
- SCL_Pin
-
Selects which pin of the I2C_Port, the SCL Clock signal will be present. There is no need to select the proper drive mode for this pin; PSoC designer will do this automatically.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is key if I2Cm is using port with other I/O -
Direct writes to the PORT used by the I2Cm User Module will interfere with I2C operation. A shadow register is automatically added for the port used by the I2Cm User Module. For example, if Port1 is used by the module, a shadow register named Port_1_DriveMode_0_SHADE is added to the project. All writes to Port1 should be done using this shadow register. For example, if Port1 bits 5 and 7 are used by the I2Cm User Module, a modification to port pin 6 could be made as follows:
C code:
Port_1_DriveMode_0_SHADE ^= 0x40;
PRT1DR = Port_1_DriveMode_0_SHADE;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I know this is an old link, but very helpful for me as I had this problem with the I2Cm and direct port writes. Is this issue with I2Cm the same if there is a HW UART (TX or RX) on the same port?
Ron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Since the HW UART has direct connections to the port pin, bypassing the port data registers, we will not face the problem.
Best regards,
Sampath Selvaraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi,
please find attachment for detail.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi,
As i am trying to attach the file it's not done. so here is the code.
system clk 24Mhz and CPU clk system clk / 2.
- I2C_Port 2
-
SDA_Pin P2_7 OPEN DRAIN LOW with 2k2 external Pullup
-
SCL_Pin P2_6 OPEN DRAIN LOW with 2k2 external Pullup
-
//----------------------------------------------------------------------------
// C main line new
//----------------------------------------------------------------------------
#include <m8c.h> // part specific constants and macros
#include "PSoCAPI.h" // PSoC API definitions for all User Modules
//#include "psocdynamic.h"
void Display(void);
BYTE rxBuf[8];
const BYTE txCBuf[] = { 0x00, // Slave internal sub-address 0
0x12,0x34,0x08, // Seconds and minutes in BCD
// 8:34:12am
0x01, // Day of Week, Monday
0x15,0x03,0x02, // Day-Month-year 15-Mar-02
0x90 }; // Enable clock output
#define DISP_MASK 0xF0
//===========================================================================================
// Alphabetic Segment Pattern
//===========================================================================================
#define _A_ 0x88
#define _b_ 0x83
#define _c_ 0xA7
#define _d_ 0xA1
#define _E_ 0x86
#define _F_ 0x8E
#define _g_ 0x90
#define _h_ 0x8B
#define _i_ 0xFB
#define _J_ 0xF1
#define _K_ 0x85
#define _L_ 0xC7
#define _M_ 0xAA
#define _n_ 0xAB
#define _o_ 0xA3
#define _P_ 0x8C
#define _q_ 0x98
#define _r_ 0xAF
#define _S_ 0x92
#define _t_ 0x87
#define _u_ 0xE3
#define _V_ 0xC1
#define _W_ 0x95
#define _X_ 0x89
#define _y_ 0x91
#define _Z_ 0xA4
//===========================================================================================
// Number Segment Pattern
//===========================================================================================
#define _0_ 0xc0
#define _1_ 0xf9
#define _2_ 0xa4
#define _3_ 0xb0
#define _4_ 0x99
#define _5_ 0x92
#define _6_ 0x82
#define _7_ 0xf8
#define _8_ 0x80
#define _9_ 0x90
//===========================================================================================
// Special charaters Segment Pattern
//===========================================================================================
#define _HYFAN_ 0xBF
#define _Ne_VE_ _HYFAN_
#define _BLANK_ 0xFF
#define _ALL_ON_ 0x00
#define _DPT_ 0x7F
const unsigned char number_code[10] = {_0_,_1_,_2_,_3_,_4_,_5_,_6_,_7_,_8_,_9_};//7_seg
BOOL toggle;
unsigned char Val2Disp,Dispcode,DispBuf[9],key_press;
unsigned int KeyCount;
long signed int Count;
//===========================================================================================
// PWM ISR
//===========================================================================================
#pragma interrupt_handler housekeeping
void housekeeping(void)
{
static unsigned int dispsel,TimeTick1msec;
PRT2DR |= 0x2f; //disable display drives
PRT1DR = 0xFF; //disable all seven segment displays
PRT1DM0 = 0xff; //make port input
PRT1DM1 = 0xff;
key_press = PRT1DR;
if((~key_press)&0xE0)
{
KeyCount++;
//DispBuf[8] &= 0x01;
}
else
{KeyCount = 0;}//DispBuf[8] &= 0x02;
PRT1DM0 = 0xff; //make port output
PRT1DM1 = 0x00;
PRT2DR &= DISP_MASK; // Change Display
PRT2DR |= dispsel; // Change Display
PRT1DR = DispBuf[dispsel]; //DispBuf[dispsel]
dispsel = (dispsel + 1) & 0x0F; // Incriment Display Selection *
}
//===========================================================================================
// Main Routine
//===========================================================================================
void main(void)
{
BYTE status; // I2C communication status
BYTE i; // Temp counter variable
PWM16_1_Start();
I2Cm_Start(); // Initialize I2C Master interface
// Set the time
status = I2Cm_bWriteCBytes(0x68,txCBuf,9,I2Cm_CompleteXfer);
M8C_EnableGInt;
PWM16_1_EnableInt();
M8C_EnableIntMask(INT_MSK0, INT_MSK0_GPIO); // C code to enable GPIO interrupt
RES_WDT = 0x38;
while(1)
{
RES_WDT = 0x38;
// In a endless loop, keep reading the time from the DS1307
do {
// Write sub-address to DS1307
// Perform a combined transfer by leaving off the Stop on the Write
// command and beginning the Read with a Repeat Start.
I2Cm_bWriteCBytes(0x68,txCBuf,1,I2Cm_NoStop );
status = I2Cm_fReadBytes(0x68,rxBuf,7,I2Cm_RepStart );
if(status == 0)
{
rxBuf = 251;// Flag an error condition
}
// This next section of code performs exactly the same sequence
// as the above code, but with low level commands.
I2Cm_fSendStart(0x68,I2Cm_WRITE); // Do a write
I2Cm_fWrite(0x00); // Set sub address
// to zero
I2Cm_fSendRepeatStart(0x68,I2Cm_READ); // Do a read
for(i = 0; i < 6; i++) {
rxBuf = I2Cm_bRead(I2Cm_ACKslave); // Read first 6 bytes,
// and ACK the slave
}
rxBuf[7] = I2Cm_bRead(I2Cm_NAKslave); // Read data byte and
// NAK the slave to signify
// end of read.
I2Cm_SendStop();
Display();
} while(1);
}
}
//************************************************************************
void Display(void)
{
unsigned int dummyvalue2display;
unsigned char handle;
dummyvalue2display = rxBuf[3];
for(handle = 0;handle <= 7;handle ++)
{
DispBuf[handle] = number_code[dummyvalue2display % 10];
dummyvalue2display/=10;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry, but as the code only shows half the project (NO settings, no modules) I cannot step through it. Try using internet explorer when attaching a project archive, this WILL work.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi,
thanks to all for valuable suggestion.
Specially Danaaknight
i use SHADE REG to change value of port 2 ,that solved my problem.
thank you againg Danaaknight
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi every body!
I'm doing a project to test I2C communication between PSoC 1 CY8C24123A and RTC DS1307.
I'm using I2Cm (P1.1 SCL, P1.0 SDA) and TX8 (P0.5, baud rate 9600) user modules.
SCL and SDA pulled up VCC (5V) by resistor 1.5k.
I want use TX8 module to send data of register 0x00 - 0x07 (from DS1307) to PC via RS232 circuit.
Link refer:
http://www.cypress.com/?rID=3049
But my project can't work!
Is this problem when I combine I2Cm and TX8 (2 communications protocol)?
Can you please check project for me?
Below it is my project.
Many thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You have no connection from your Tx8 output. Select an appropiate pin and that should work.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content