Sample program using the STOP instruction for low power mode with the 68HC11
#include <hc11.h>
#include "pia.h"
#include "rtc.h"
#include "spi.h"
#define TRUE 1
void irq_isr(void);
struct rtc_regs rtc;
unsigned char time[10000];
unsigned int time_index;
main()
{
time_index = 0;
setup_spi(SPI_ENABLE | SPI_MASTER | SPI_CPOL_ZERO | SPI_CPHASE_ONE
| SPI_CLOCK_E_DIV2);
/* Set the RTC to the current time */
setup_rtc();
/* The following instructions clear the STOP bit of the CCR */
asm(" tpa");
asm(" anda 0x7f");
asm(" tap");
enable();
while (TRUE)
{
asm(" stop");
}
}
void irq_isr(void)
/* In ISR, read the time from the clock and save in data array;
* read_rtc() resets interrupt flip flop when Slave Select (Port D Bit 5)
* goes high
*/
{
read_rtc(&rtc);
time[time_index++]=rtc.year;
time[time_index++]=rtc.month;
time[time_index++]=rtc.dom;
time[time_index++]=rtc.hour;
time[time_index++]=rtc.min;
time[time_index++]=rtc.sec;
}