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 support@ccsinfo.com

Problem with DS3231 and PIC16F1847
Goto page Previous  1, 2, 3, 4  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
jake1272



Joined: 15 Mar 2021
Posts: 37

View user's profile Send private message

PostPosted: Sun Apr 11, 2021 12:38 pm     Reply with quote

Yes, I have done that as well. Sad I even replaced the DS3231 still
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Apr 11, 2021 3:01 pm     Reply with quote

I don't see that CCS has a ds3231.c driver file.

I have vs. 5.103 installed and these are all the files starting with "ds":
Quote:

06/23/2003 03:45 PM 1,928 ds1868.c
06/23/2003 03:48 PM 2,862 ds1624.c
06/23/2003 03:49 PM 4,149 ds1621m.c
06/23/2003 03:49 PM 3,613 ds1621.c
08/06/2004 02:09 PM 50,555 ds2432.c
08/17/2005 11:00 AM 3,055 ds1631mm.c
03/02/2010 02:35 PM 20,648 ds1993.c
08/06/2013 09:39 AM 4,909 ds1302.c
08/06/2013 09:42 AM 5,107 ds1338.c
12/22/2014 03:02 PM 9,768 ds1305.c
08/12/2016 02:01 PM 25,548 dsp_data_util.c
09/16/2016 08:04 AM 8,068 ds18b20.c
04/22/2019 01:49 PM 2,723 ds1631.c
11/04/2020 02:13 PM 37,893 ds18B20_multidrop.c

I don't think you got the driver from CCS.
Post a link to the website where you got the driver, so we can look at it.
temtronic



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

View user's profile Send private message

PostPosted: Sun Apr 11, 2021 4:31 pm     Reply with quote

Found it !!!! well, I think so....

https://simple-circuit.com/ds3231-rtc-driver-ccs-c-compiler/

He had the driver in the original post, but removed it, as moderator thought it was an official CCS product.....

Jay
dyeatman



Joined: 06 Sep 2003
Posts: 1912
Location: Norman, OK

View user's profile Send private message

PostPosted: Sun Apr 11, 2021 4:42 pm     Reply with quote

Actually that was me.
It appeared to have the CCS Header and it was in the CCS driver directory in
the example so I alerted him about it.
I do'nt see it in my listing either.
_________________
Google and Forum Search are some of your best tools!!!!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Apr 11, 2021 10:48 pm     Reply with quote

jake1272 wrote:
Yes, I have done that as well. Sad I even replaced the DS3231 still

What are your connections to the Vbat and RST pins on the ds3231 ?

What is the voltage on the Vcc pin of the ds3231 ?

What is the PIC's Vdd voltage ?
jake1272



Joined: 15 Mar 2021
Posts: 37

View user's profile Send private message

PostPosted: Mon Apr 12, 2021 12:32 am     Reply with quote

temtronic wrote:
Found it !!!! well, I think so....

https://simple-circuit.com/ds3231-rtc-driver-ccs-c-compiler/

He had the driver in the original post, but removed it, as moderator thought it was an official CCS product.....

Jay


Yes I got the driver from that website you have mentioned
jake1272



Joined: 15 Mar 2021
Posts: 37

View user's profile Send private message

PostPosted: Mon Apr 12, 2021 12:43 am     Reply with quote

PCM programmer wrote:
jake1272 wrote:
Yes, I have done that as well. Sad I even replaced the DS3231 still

What are your connections to the Vbat and RST pins on the ds3231 ?

What is the voltage on the Vcc pin of the ds3231 ?

What is the PIC's Vdd voltage ?

PIC's Vdd voltage = 5V
Vcc pin on DS3231 =5V
For Vbat and RST I don't have those pins .I only have vcc, sda,scl ,sqw,32k, and ground

I Use PIN_A0 for SDA
I Use PIN_A1 for SCL


Last edited by jake1272 on Mon Apr 12, 2021 12:59 am; edited 1 time in total
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Apr 12, 2021 12:55 am     Reply with quote

I think you mean that you're using a module with a battery installed on
the back side of the board.

Is there a battery installed ? Can you measure the voltage of it ?
Ttelmah



Joined: 11 Mar 2010
Posts: 19222

View user's profile Send private message

PostPosted: Mon Apr 12, 2021 12:59 am     Reply with quote

Are you using some sort of board with the chip?. If so, does this have a battery
on it?. If so, this is the 'Vbat'.
The chip will not keep time when switched off, without a battery. If this pin
is not used, it needs to be connected to the 0v. You can't just not connect it.
Post what board you are using?. A link to the site where it has come from?.
Just as for this pin, all the 'NC' pins on the chip _must_ be connected to
0v.
Now you can run with Vcc connected to the Vbat pin. If this is done, the Vcc
pin needs to connect to 0v, and there must be a decoupling capacitor on the
Vbat pin.
These 'details' are what affects how the unit will work.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Apr 12, 2021 1:01 am     Reply with quote

I looked at the simple circuits page that has CCS code for the ds3231.
https://simple-circuit.com/ds3231-rtc-driver-ccs-c-compiler/
It shows the following main() function. Notice that he initializes the RTC
chip with the date and time. You cut that out.

Why not just copy his code exactly ?
Code:

void main()
{
  delay_ms(1000);  // wait a second
  lcd_init();
  lcd_putc('\f');
 
  // read current time and date from the RTC chip
  mytime = RTC_Get();
  // print them
  rtc_print();
 
  delay_ms(1000);  // wait a second
 
  // set RTC time to 21:08:47 (hh:mm:ss) and date to 03-01-19 (dd-mm-yy)
  mytime->hours   = 21;
  mytime->minutes = 8;
  mytime->seconds = 47;
  mytime->dow     = THURSDAY;
  mytime->day     = 3;
  mytime->month   = JANUARY;
  mytime->year    = 19;
  // write time and date to the RTC chip
  RTC_Set(mytime);
 
  // enable SQW output with frequency of 1Hz
  IntSqw_Set(OUT_1Hz);
 
  while(TRUE)
  {
    // read current time and date from the RTC chip
    mytime = RTC_Get();
    // read chip temperature
    chip_temp = Get_Temperature();
    // print all data
    rtc_print();
 
    delay_ms(100);  // wait 100 ms
 
  }
 
}
jake1272



Joined: 15 Mar 2021
Posts: 37

View user's profile Send private message

PostPosted: Mon Apr 12, 2021 1:01 am     Reply with quote

PCM programmer wrote:
I think you mean that you're using a module with a battery installed on
the back side of the board.

Is there a battery installed ? Can you measure the voltage of it ?


Yes there is a battery installed on the back with 3.6V
jake1272



Joined: 15 Mar 2021
Posts: 37

View user's profile Send private message

PostPosted: Mon Apr 12, 2021 1:44 am     Reply with quote

Similar DS3231:https://www.digitspace.com/ds3231-rtc-module-real-time-clock-module-at24c32-high-accuracy
Jerson



Joined: 31 Jul 2009
Posts: 122
Location: Bombay, India

View user's profile Send private message Visit poster's website

PostPosted: Mon Apr 12, 2021 4:24 am     Reply with quote

To begin with debugging your code, I would

* comment all calls to the RTC driver functions.
* Replace the print statement with dummy values for each variable you print
* If you succeed with this, then re-enable RTC_get and check if it prints some values

Unless this works, do not check other RTC functions.
temtronic



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

View user's profile Send private message

PostPosted: Mon Apr 12, 2021 5:05 am     Reply with quote

a comment...

I do the lcd_init() THEN the delay_ms(1000).
This ensures the LCD module has more than enough time to do it's 'setup'.
Depending on who wrote the LCD driver, there may or may not be a long enough delay for the LCD module being used.
It also allows external peripherals time to properly 'powerup'.
Ttelmah



Joined: 11 Mar 2010
Posts: 19222

View user's profile Send private message

PostPosted: Mon Apr 12, 2021 7:19 am     Reply with quote

Actually, delaying first is more normally what is needed....

Problem is that the standard Hitachi LCD controller carefully specifies that
it can accept commands just 15mSec after the supply comes on. However
a lot of the 'clone' LCD's need longer, and also many of the LCD's don't
actually 'start' this time, till the supply has risen further than the PIC needs
to start.

I suspect you use PCM Programmer's flex LCD driver. this allows 35mSec
for the display boot, so normally works. However the poster here is using the
CCS driver, and this often has problems unless a little extra time is allowed
before lcd_init is called.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2, 3, 4  Next
Page 2 of 4

 
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