📄 main.c
字号:
#include "mb90425.h"
/*---------------------------------------------------------------------------
#Defines
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
Globals
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
Functions
/*---------------------------------------------------------------------------*/
/* Note:
The -A and -B versions include a CPU Detection Reset Circuit.
This must be cleared periodically to prevent program reset.
The conditions for clearing the counter of this circuit are given below:
1. Writing 0 to CL bit of LVRC register
2. Internal reset
3. Stopping main oscillation clock
4. Transition to sleep mode
5. Transition to time-base timer mode or timer mode
6. Starting hold
*/
void clear_CPU_operation_detection (void)
{
LVRC = 0x35; /* clears CPU operation detection */
}
/*---------------------------------------------------------------------------
Functions: Real-Time Watch-Timer
/*---------------------------------------------------------------------------*/
void Init_RealTimeWatchTimer(unsigned char hours,
unsigned char minutes,
unsigned char seconds)
{
WTCRL = 0x00; /* stop Real-Time Watch-Timer */
WTBRH = 0x1E; /* Set Prescaler to 0x1E847F ... */
WTBRM = 0x84; /* ... that means 1 second @ 4Mhz */
WTBRL = 0x7F; /* Note: Prescaler is based on the half crystal clock */
WTSR = seconds; /* Preset seconds */
WTMR = minutes; /* Preset minutes */
WTHR = hours; /* Preset hours */
WTCRH = 0x02; /* enable Interrupts for sub-seconds-overflow */
WTCRL = 0x05; /* start Real-Time Watch-Timer */
}
/*---------------------------------------------------------------------------
Interrupts
/*---------------------------------------------------------------------------*/
__interrupt void irq_RealTimeWatch (void)
{
PDR4 = ~(WTSR & 0x3f); /* put seconds-register tor Port 4 (LED-Port of FlashCan100P */
WTCRH = 0x02; /* clear Interrupt Flag */
}
/*---------------------------------------------------------------------------
MAIN.C
/*---------------------------------------------------------------------------*/
void main(void)
{
InitIrqLevels();
__set_il(7); /* allow all levels */
__EI(); /* globaly enable interrupts */
PDR4 = 0xFF; /* switch off all leds */
DDR4 = 0xFF; /* set parallel port direction register : output */
Init_RealTimeWatchTimer(0,0,6); /* Initialize Real-Time Watch-Counter */
while(1)
clear_CPU_operation_detection();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -