Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Mikroc for PCF8593 + PIC18F452 + LCD in Proteus showing unexpected character

Status
Not open for further replies.
Hi rajib.das and jayanth;

I'm sorry, but I just now noticed that the MikroE example uses PCF8583 and the PCF8593 is different (see the datasheets). The biggest (?) difference is in the addresses, the write address of the PCF8593 is 0xA2 (against the PCF8583's value of 0xA0). The read address is also different: 0xA3 (not 0xA1).
And .. may be different contents of registers as well ...
 
File attached. HW I2C is not working. I hope somebody can fix it.

97720d1382703294-pcf8593.png


- - - Updated - - -

@ rajib

If you can use RC3 and RC4 then better use hardware I2C.



Edit2: Fixed the hardware version. It is working fine now.

http://www.libstock.com/projects/view/815/rtc-pcf8593-clock

http://www.libstock.com/projects/view/816/hw-i2c-based-pcf8593-rtc-project
 

Attachments

  • RTC PCF8593 Soft I2C.rar
    82.6 KB · Views: 78
  • RTC Read HW I2C.rar
    81.4 KB · Views: 76
  • pcf8593.png
    pcf8593.png
    178.8 KB · Views: 142
  • RTC Read HW I2C.rar
    83.2 KB · Views: 64
Last edited:

Attachments

  • RTC PCF8593 Soft I2C rev1.rar
    85.7 KB · Views: 73
Last edited:
Yay!!!!
Congrats! Its all happening on the right way. Thanks guys.
@Jayanth, you r genius and kind man. it s all working fine. (need your attention on reading the year though . should be 2013 not 2011 )
I compared your modules with my original project. And finally I abled to get my RTC working too.
Changes I had to make on read and write addresses. Thanks Zuisti.
I was using the example with PCF8583 with write address 0xA0 and read address 0xA1
I Had to change it for PCF8593 with write address 0xA2 and read address 0xA3....Bingo...works fine
Didn't need any other modification even I dint had to sacrifice the 1 k resister series to SDA or even negotiate with 10K pull up shunt resisters to 4.7k as long as its supplying SDA voltage between 3.5 to 5.5v.Its even working with RC0 for initiate the clock.

Still I don't have confidence on how to find out the address value from Data sheet. Probly You guys can share me some tricks. I read on and on the both data sheets(8583 and 8593) before start this module to find the difference .I couldn't find any ?

One thing I have become pretty clear about Making difference between Soft i2c(applicable for any pin) and hardware i2c library(Only for default SDA and SLC pin ; RC3:RC4). Now looking forward to use i2c1 and i2c2 for hooking second device EEPROM on I2C bus. Pls do share any suggestion ...will be much appreciated. My understanding is still clouded about i2c1 and i2c2 .Thanks.

Thanks for everything . I am so impressed about how good this online forum and how skilled its members are. Go EDA GO......
Thanks Jayanth, Zuisti, Venkadesh, nick and mathes
 

Not sure yet. I am still going through the Data Sheet I attached for EEPROM, Still figuring out the Address Stuff. Don't want to mess it again with address selection. So far I know I have use sequential read and write mode.

So u think I don't have to change soft_i2c to I2c. I only need to use eeprom on i2c and its gonna work fine without any conflict!
 

Attachments

  • PicDem2plusEEPROM24AA256_24LC256_24FC256.pdf
    447.3 KB · Views: 66

Yes you can use your soft I2C for EEPROM as well the only change is slave address, you know guys the complexity of finding mistake in RTC is increased by EEPROMs response for A0 and A1. That acknowledged the I2C bus for signal sent to RTC, I have found that when I have disconnected the EEPROM.... so that is also one of the addresses on the EEPROM and before doing experimentations read the documentation well......

Look at the Page 8 for slave address, read full reading and writing sequences before going in to the program..
 

Attachments

  • RTC PCF8593 + EEPROM 24LC256 Soft I2C.rar
    96.8 KB · Views: 76
  • RTC PCF8593 + EEPROM 24LC256 Hw I2C.rar
    98.8 KB · Views: 55
  • RTC PCF8593 + EEPROM 24LC256 Hw I2C rev3.rar
    102.6 KB · Views: 73
  • rtceep.png
    rtceep.png
    199.4 KB · Views: 134
Last edited:

@Jayanth...
I owe you a lot of thanks.
I was late to response because I was trying to fit your concept in my projects and make it work..

I tried both soft_i2c and i2c1 and their combination too.

I know all the techniques should work fine.....but I only got the soft_i2c does best for me. in i2c1 method I was having some interrupts.

anyway I still have few problem to solve before I proceed to next step.

1..How did you manage to solve the year problem? I am still having 2011 normally unless I wanna temper the code by adding 50 instead of 48 in lcd out protocol. which is not the proper value for the last bit of year.

2 ..I am experiencing a issue with pointers to perform write and read ant chunk of string on EEPROM. its only writing or reading first letter
at least on my LCD say, showing M instead of "MIKRO.........". I am playing with the responsible pointer now. Some help from you would be nice. thanks .FYI I am using exactly similar code to yours.

3.. is there any mikroC function to get size of pointer?

Bro, I am dealing with a big solar panels charge controller plus meter. The Guy who build it has left the planet as well as his code.
All we have is his hardware designee and fully operational meter and its programmed chip.

My job is to apply reverse engineer on his work and improve the system eventually.

You probly thinking why I am explaining to you? because you gonna be bored soon to see me here all the time banging my head with different silly issues.

thanks
 

How did you manage to solve the year problem?

I managed to solve the problem by reading the datasheet.

sizeof() returns the size of variable, even pointer. Even I had problem with function returning a string. I used char array instead of string pointer. You can see that "mikroElektronika" is written to eeprom and then read back and displayed on LCD.

Provide the exact circuit of your hardware, I will try to write a working code for it.


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
void Write_Time(){
 
      I2C1_Start();      // Issue start signal
      while (I2C1_Is_Idle() == 0);
      I2C1_Wr(0xA2);  // Address PCF8583, see PCF8583 datasheet
      while (I2C1_Is_Idle() == 0);
      I2C1_Wr(0);     // Start from address 0 (configuration memory location)
      while (I2C1_Is_Idle() == 0);
      I2C1_Wr(0x80);  // Wr 0x80 to configuration memory location (pause counter...)
      while (I2C1_Is_Idle() == 0);
      I2C1_Wr(0);     // Wr 0 to cents memory location
      while (I2C1_Is_Idle() == 0);
      I2C1_Wr(0x11);     // Wr 0 to seconds memory location
      while (I2C1_Is_Idle() == 0);
      I2C1_Wr(0x30);  // Wr 0x30 to minutes memory location
      while (I2C1_Is_Idle() == 0);
      I2C1_Wr(0x17);  // Wr 0x12 to hours memory location
      while (I2C1_Is_Idle() == 0);
      I2C1_Wr(0xE6);  // Wr 0x18 to year/date memory location
      while (I2C1_Is_Idle() == 0);
      I2C1_Wr(0x2A);  // Wr 0x04 to weekday/month memory location
      while (I2C1_Is_Idle() == 0);
      I2C1_Stop();       // Issue stop signal
 
      I2C1_Start();      // Issue start signal
      I2C1_Wr(0xA2);  // Address PCF8530
      while (I2C1_Is_Idle() == 0) ;
      I2C1_Wr(0);     // Start from address 0
      while (I2C1_Is_Idle() == 0) ;
      I2C1_Wr(0);     // Wr 0 to configuration memory location (enable counting)
      while (I2C1_Is_Idle() == 0) ;
      I2C1_Stop();       // Issue stop signal
}

 
Last edited:

@Jayanth...
hey man sorry for going on same thing over and over. Fact is I still could not figure out the year problem which actually bothering a critical part of my project. Although I have gained much improved skill on reading datasheets which still seems like not enough to get year 13 instead of 11. Please man if u could provide some tips would be much appreciated....
 

I used
HTML:
year     =   (day & 0xE5) >> 6;
and its never worked. Is there any thing I am missing?


I also have another trouble. My project RTC circuit has no external pull up resister (4.7k or 10k) to SCL pin. And I suppose to make it work without it.

RTC.jpg

is there any internal pull up option for pic18f452 on pin RC3
 

Thanks Man
It is working!!!!
@Jayanth... you are Genius.

And Do you have any suggestion for internal pull up for p18f452 to solve the other problem.
I must have to find a way to do it.


thanks
 

As my project requirement our RTC circuit has no external pull up resister (4.7k or 10k) to SCL pin. And I suppose to make it work without it. RTC.jpg
 

can I do it on RC3 pin with software_I2C .
Do you have any example?
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top