PIC16F18877 RTC-Read from DS1307

Discussion on both general simulation and Proteus VSM microcontroller simulation.
Post Reply
Microwitsch
Professional User
Posts: 4
Joined: Fri 2024-01-26 21:24

PIC16F18877 RTC-Read from DS1307

Post by Microwitsch »

Hello everyone,

The DS1307 sends no Ack for writing the Chipadress 0xD0?
What's wrong with this simple project? I'm a beginner, sorry...

build with Mplab XC8 v2.31
Attachments
16F18877simpI2Cread.pdsprj
(32.75 KiB) Downloaded 12 times
Ettore
Labcenter Staff
Posts: 2931
Joined: Fri 2006-03-03 11:56
Location: Milan
Contact:

Re: PIC16F18877 RTC-Read from DS1307

Post by Ettore »

Hi
I found a couple of bugs in that PIC16 family VSM model which we'll fix as soon as possible.

I attach a version of your code that I have modified to work as expected. Substantially I've improved your I2C code to make it more reliable and made a workaround because of simulated PIC16 bugs. I recommend not to use the external interrupt INT on RB0 (or other pins as well) as for some reason it won't work. Please use the IOC interrupt instead. I can PM you with a version that uses IOC interrupts if you don't know how to.
16F18877simpI2Cread_1.pdsprj
(33.26 KiB) Downloaded 8 times
Kind regards,
Ettore Arena - Labcenter Electronics.
Microwitsch
Professional User
Posts: 4
Joined: Fri 2024-01-26 21:24

Re: PIC16F18877 RTC-Read from DS1307

Post by Microwitsch »

Hello Ettore,

Thanks for the quick answer! I'll take a look at your attachment. 8)
I found a few errors in my program.

I had reached the wrong value for "SSP1ADD", which is now a value of 0x13 at an instruction frequency of 8Mhz. And the oscillator registers also had incorrect values , which I have now adjusted. But no success, I suspected a frequency setting error. In the meantime, I found another, simple example which I am attaching here. What influence does the frequency that you can see for the PIC as shown in the screenshot actually have? independently sets?Which one is validin the simulation?
proteussim.png
I found a simpler example (smaller controller) on the site here and analyzed it as best I could in order to adapt it for the PiC16f18877. The PIC is very extensive with the registers (900pages documentation) but it seemed good to me to respond to a universal one.https://embetronicx.com/tutorials/micro ... -tutorial/
PIC16I2DsimpleLCDeepromDemo.pdsprj
Microwitsch
Professional User
Posts: 4
Joined: Fri 2024-01-26 21:24

Re: PIC16F18877 RTC-Read from DS1307

Post by Microwitsch »

Ettore wrote: Mon 2024-03-25 10:30 Hi
I found a couple of bugs in that PIC16 family VSM model which we'll fix as soon as possible.

I attach a version of your code that I have modified to work as expected. Substantially I've improved your I2C code to make it more reliable and made a workaround because of simulated PIC16 bugs. I recommend not to use the external interrupt INT on RB0 (or other pins as well) as for some reason it won't work. Please use the IOC interrupt instead. I can PM you with a version that uses IOC interrupts if you don't know how to.

16F18877simpI2Cread_1.pdsprj
Thanks Ettore, that looks much better!...ok, I'll take a look at it then. :D
Ettore
Labcenter Staff
Posts: 2931
Joined: Fri 2006-03-03 11:56
Location: Milan
Contact:

Re: PIC16F18877 RTC-Read from DS1307

Post by Ettore »

The bugs about the default PPS I2C output pins settings and external interrupt INT to RB0 have been now fixed.
The fix will be in the next service pack.
Kind regards,
Ettore Arena - Labcenter Electronics.
Post Reply