Hi Filipe, It helps if you send your program otherwise we are comparing apples with pears.
There is another possibility. Your PIC has a secondary oscillator, meant for connecting a 32 kHz crystal. If you use that, you can make your own RTC and the only thing you need is a 32 kHz crystal and a small piece of software. Kind regards, Rob ________________________________ Van: [email protected] <[email protected]> namens flyway38 <[email protected]> Verzonden: woensdag 11 januari 2023 14:53 Aan: jallib <[email protected]> Onderwerp: Re: [jallib] PIC16F19176 rtc help Hello Vasile, I think that have already tried that sample, but as said before, think i fall into some LIB errors... Will check again, but maybe get stuck while adapting it to my PIC... Will back here with results. Thank you very much. Cheers, FS On Wednesday, January 11, 2023 at 3:50:33 AM UTC vasile wrote: Hi Fellipe, You will not like my ideea but any rtc can be implemented in any pic, much better than using an external RTC, by using Bresenham zero error algorithm. It's in the sample and works perfect with all timers. It's set to seconds but works down to 1ms for fast pics. You have just to set a flag in the isr when time passed and reset it in the main after you have read it. The only thing to care is the total lenght of your isr, including your own application which must be shorter than time genetated (aka 1 second or shorter). On Tue 10 Jan 2023, 9:25 PM flyway38 <[email protected] wrote: Hi Rob, It seems something not working... Not sure why, but using your sample (part of it, check below what have integrated in my code from your sample), it doesn't even reach the FOREVER LOOP... Maybe because am using serial_hw_int_cts instead of serial_hardware, or even because am using timer0_isr_interval... don't know... Here's what am using from your sample: -- Settings for the RTC and intialization. alias rtc_sck is pin_C0 -- Pin 10 for 14 pin DIP alias rtc_sck_direction is pin_C0_direction alias rtc_sdo is pin_C1 -- Pin 9 for 14 pin DIP. alias rtc_sdo_direction is pin_C1_direction -- If you want to use software IIC, define the following constant. -- const RTC_SOFTWARE_IIC = TRUE include rtc_ds3231 -- Setting to check the alarm on a poll basis or interrupt bases. When -- defined the alarms are checked using the external interrupt of the PIC. -- Using the interrupt has its limitations for this rtc as explained in the -- sample interrupt routine below. -- const ALARM_ON_INTERRUPT = TRUE -- Print the current time of the rtc. procedure print_time() is var byte hours, minutes, seconds rtc_get_time_bin(hours, minutes, seconds) print_string(serial_hw_data, "H:") print_byte_dec(serial_hw_data, hours) print_string(serial_hw_data, " M:") print_byte_dec(serial_hw_data, minutes) print_string(serial_hw_data, " S:") print_byte_dec(serial_hw_data, seconds) print_crlf(serial_hw_data) end procedure -- Example of handling the alarm on an interrupt basis. Note that we cannot -- call any of the RTC procedures because it will interfere with the IIC -- transmission. We can only set a flag that can be checked later. Note that -- the interrupt is edge triggered. The rtc interrupt stays low as long as -- the alarm flag of the RTC is set. if defined(ALARM_ON_INTERRUPT) then procedure alarm_interrupt is pragma interrupt if INTCON_INTF then INTCON_INTF = FALSE alarm_was_given = TRUE end if end procedure end if rtc_init() -- Enable interrupts if setting is defined. if defined(ALARM_ON_INTERRUPT) then INTCON_INTE = TRUE -- Interrupt on falling edge. OPTION_REG_INTEDG = FALSE INTCON_GIE = TRUE rtc_enable_alarm_1_interrupt() rtc_enable_alarm_2_interrupt() end if Don't need to use any Alarms... But need to use Timer Interval to do some checks regularly. Anyways, have put just before FOREVER LOOP: -- Set some intial time hh:mm:ss in binary format and print it. rtc_set_time_bin(18, 51, 30) print_time() This code doesn't run... Any ideas? Thank you very much. FS On Tuesday, January 10, 2023 at 6:45:27 PM UTC flyway38 wrote: Hi Rob, Wow. Thank you very much for the fast reply. Will check and back here with results. Cheers, FS On Tuesday, January 10, 2023 at 6:35:45 PM UTC [email protected] wrote: Hi Filipe, I took the sample program 16f1825_rtc_ds3231.jal and changed it for the 16f19176. No compiler issues. See attachment. Kind regards, Rob ________________________________ Van: [email protected] <[email protected]> namens flyway38 <[email protected]> Verzonden: dinsdag 10 januari 2023 19:04 Aan: jallib <[email protected]> Onderwerp: [jallib] PIC16F19176 rtc help Hello all, Need help on coding for an rtc for the 16F19176. Have tried many samples with no luck. They get alot of failures, like not defined terms... Need to implement a simple RTC code to keep track of time even if PIC is handling "closed loop" routines, like reading Comm Port or resetting the gsm modem, etc... Need these routines to get interrupted, and finished after RTC updates time. It would be a very fast code, only to increment a variable. Need some sample code adapted for this PIC, please. Thank you Kind regards, Filipe Santos -- You received this message because you are subscribed to the Google Groups "jallib" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jallib/4b03768d-331b-4a4c-aa10-afbf73fc952cn%40googlegroups.com<https://groups.google.com/d/msgid/jallib/4b03768d-331b-4a4c-aa10-afbf73fc952cn%40googlegroups.com?utm_medium=email&utm_source=footer>. -- You received this message because you are subscribed to the Google Groups "jallib" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jallib/792ae118-9ffe-496b-b214-9ef697d45133n%40googlegroups.com<https://groups.google.com/d/msgid/jallib/792ae118-9ffe-496b-b214-9ef697d45133n%40googlegroups.com?utm_medium=email&utm_source=footer>. -- You received this message because you are subscribed to the Google Groups "jallib" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]<mailto:[email protected]>. To view this discussion on the web visit https://groups.google.com/d/msgid/jallib/2cd70652-2a40-4954-bfef-1b9ec4730363n%40googlegroups.com<https://groups.google.com/d/msgid/jallib/2cd70652-2a40-4954-bfef-1b9ec4730363n%40googlegroups.com?utm_medium=email&utm_source=footer>. -- You received this message because you are subscribed to the Google Groups "jallib" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jallib/GVXP195MB16377FF3705503B6715619CFE6FC9%40GVXP195MB1637.EURP195.PROD.OUTLOOK.COM.
