Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

DS3232 and PIC....

Status
Not open for further replies.

Wond3rboy

Member
Hi i am trying to program the DS3232 to generate an interrupt every second. But even after following the right directions, it just isn't getting done. I can generate a square wave of various frequencies but am not able to generate the Alarm Interrupt per second.

Code:
Delay1KTCYx(500);// Let the RTC Startup
	Write_DS3232(Control,0x85);
	while(SSPCON2bits.ACKSTAT!=0);// wait for ack from RTC
	Write_DS3232(Seconds,0x00);
	while(SSPCON2bits.ACKSTAT!=0);// wait for ack from RTC
	Write_DS3232(Minutes,0x00);
	while(SSPCON2bits.ACKSTAT!=0);// wait for ack from RTC
	Write_DS3232(Hours,0x12);
	while(SSPCON2bits.ACKSTAT!=0);// wait for ack from RTC
	Write_DS3232(Day,0x01);
	while(SSPCON2bits.ACKSTAT!=0);// wait for ack from RTC
	Write_DS3232(Date,0x01);
	while(SSPCON2bits.ACKSTAT!=0);// wait for ack from RTC
	Write_DS3232(Month_Century,0x01);
	while(SSPCON2bits.ACKSTAT!=0);// wait for ack from RTC
	Write_DS3232(Year,0x10);
	while(SSPCON2bits.ACKSTAT!=0);// wait for ack from RTC
[B]	Write_DS3232(Alarm1_seconds,0x80);
	while(SSPCON2bits.ACKSTAT!=0);// wait for ack from RTC
	Write_DS3232(Alarm1_minutes,0x80);
	while(SSPCON2bits.ACKSTAT!=0);// wait for ack from RTC
	Write_DS3232(Alarm1_hours,0x80);
	while(SSPCON2bits.ACKSTAT!=0);// wait for ack from RTC
	Write_DS3232(Alarm1_day_date,0x80);
	while(SSPCON2bits.ACKSTAT!=0);// wait for ack from RTC
	Write_DS3232(Control,0x05);
	while(SSPCON2bits.ACKSTAT!=0);// wait for ack from RTC[/B]

I want you guys to look at the bold lines of code. According to the Datasheet of the DS3232(PG# 12) I have written 1 on each of the Four Bit masks but for some reason the RTC is not generating an interrupt every second. All Data Transfer routines are correct. They are working.

https://www.electro-tech-online.com/custompdfs/2010/06/DS3232.pdf
Thanks.
 
Last edited:
Hi, i checked my code with the example given in the application note.

**broken link removed**


I found that i have written the correct code and there is some problem with the Proteus model(already told my university to complain to the Labcenter Guys). Well since i had written the code, i continued with it and instead of using the alarm interrupts i have used the square wave feature(added the necessary substitutions for Alarm interrupts).Here is the code and the simulation in proteus. I would have made it in hardware but i dont have no $$$ :(.
 

Attachments

  • I2C.zip
    8.5 KB · Views: 241
  • 18f4620i2c.zip
    19.9 KB · Views: 214
Status
Not open for further replies.

Latest threads

Back
Top