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