Hi Rob,

Thank you for your information.
Will test and back here with results.

Cheers,
FS

On Thursday, January 12, 2023 at 5:55:18 PM UTC [email protected] wrote:

> Hi Filipe,
>
> That timer library is using interrupts but if the code in your forever 
> loop has a delay you will not benefit from it.
>
> So what should be done is that the action you want to execute when the 
> timer has an interrupt should be part of that timer0 interrupt routine and 
> not in your forever loop. Some libraries - but not this one - have an 
> option to call a user defined procedure when it is defined.
>
> A quick - and dirty - fix is to make a local copy of this timer library 
> and add your specific code to the procedure ISR() in timer0_isr_interval. 
> Note that when you do that, your code must be fast since interrupt routine 
> should be a short as possible.
>
> An option would be to extend this library and call a user defined 
> procedure from the timer interrupt if it was defined by the user.
>
> Kind regards,
>
> Rob
>
> ------------------------------
> *Van:* [email protected] <[email protected]> namens flyway38 <
> [email protected]>
> *Verzonden:* donderdag 12 januari 2023 12:02
>
> *Aan:* jallib <[email protected]>
> *Onderwerp:* Re: [jallib] PIC16F19176 rtc help
> Hello Rob,
>
> Yes, am using this code:
> -- This program uses the internal oscillator at 32 MHz.
> pragma target clock    32_000_000  -- oscillator frequency
> pragma target OSC      OFF         -- internal oscillator
> pragma target RSTOSC   HFINT32     -- select 32 MHz
> pragma target CLKOUTEN DISABLED    -- no clock output
> pragma target WDT      DISABLED    -- watchdog
> pragma target BROWNOUT DISABLED    -- no brownout reset
> pragma target FCMEN    DISABLED    -- no clock monitoring
> pragma target CSWEN    ENABLED     -- allow writing OSCCON1 NOSC and NDIV
> pragma target LVP      ENABLED     -- low voltage programming
> pragma target MCLR     INTERNAL    -- internal reset
> --
> OSCFRQ_HFFRQ = 0b110               -- Fosc 32 -> 32 MHz
> --OSCCON2 = 0x00                   -- 32 MHz and no division
> --
> -- Enable weak pull up for all inputs.
> --WPUA = 0b1111_1111
> WPUB = 0b1111_1111
> WPUC = 0b1111_1111
> WPUD = 0b1111_1111
> WPUE = 0b0000_1111
>
> ...
>
> -- Timer0_isr_interval Lib
> const DELAY_SLOTS = 1              -- support 2 delays at the same time
> const word TIMER0_ISR_RATE = 1000  -- 1 kHz isr rate
> include timer0_isr_interval
> timer0_isr_init()                  -- init timer0 isr
> --
> set_delay(0, 2_000)                -- Init timer0 pointer
> var word wTimeSync = 0             -- Init Time Sync clock
>
> And inside FOREVER LOOP:
>    -- Checking TIMER0 - Time Sync
>    if (check_delay(0)) then
>       wTimeSync = wTimeSync + 1
>       --
>       -- ticks (of 2s) on delay-slot 0
>       set_delay(0, 2_000)
>       --
>      if (!LedAM & wTimeSync%10 == 0) then 
>          Krnl_CheckModem()
>       end if
>    end if
>
> Problem is this code don't use interrupts.
> So my var "wTimerSync" don't get updated when PIC is doing longer time 
> consuming tasks...
> Can you help?
> Thank you.
>
> Cheers,
> FS
> On Thursday, January 12, 2023 at 9:59:11 AM UTC [email protected] wrote:
>
> Hi Filipe,
>
> In that case you could use a timer. Did you have a look at a timer library?
>
> Met vriendelijke groet,
> Rob Jansen 
> ------------------------------
> *From:* [email protected] <[email protected]> on behalf of 
> flyway38 <[email protected]>
> *Sent:* Thursday, January 12, 2023 10:16:41 AM
> *To:* jallib <[email protected]>
> *Subject:* Re: [jallib] PIC16F19176 rtc help 
>  
> Hi Rob and Vasile,
>
> Thank you for your input.
> My code is very big (and confuse) by now.
> Anyways, only need an effective RTC to increment a variable, no matter 
> what PIC is doing...
> Problem is I have no experience using interrupts (software ones) with PICs.
>
> Good point about that second oscillator. Remember now, my eyes crossing 
> that info in the datasheet...
> But, I think that will not need that. I don't need a precise RTC. My code 
> will use a time base of 10seconds.
> Problem is when PIC is doing some actions like reading SMSs, deleting 
> SMSs, resetting modem, etc.... those actions take almost a minute, so I 
> need interrupts to keep track of elapsed time.
> Thank you very much.
>
> Cheers,
> FS
>
> On Thursday, January 12, 2023 at 5:09:14 AM UTC vasile wrote:
>
> Yep. If a secondary oscillator available, definitely yes for the RTC, 
> except maybe for running at -20C where a good TCXO is expensive, using only 
> one could be an option.
> Apples with pears are still fruits, not very bad comparison. :)
>
> On Wed, Jan 11, 2023 at 7:46 PM Rob CJ <[email protected]> wrote:
>
> 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].
> 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
>  
> <https://groups.google.com/d/msgid/jallib/GVXP195MB16377FF3705503B6715619CFE6FC9%40GVXP195MB1637.EURP195.PROD.OUTLOOK.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/6c46fd5a-b3a9-496f-8d8e-c4359afdf30en%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/jallib/6c46fd5a-b3a9-496f-8d8e-c4359afdf30en%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/2eac187a-5f82-426a-a2ea-db33470f1236n%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/jallib/2eac187a-5f82-426a-a2ea-db33470f1236n%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/208ee8db-bda5-48f6-b978-fb0af4f03952n%40googlegroups.com.

Reply via email to