📄 main.c
字号:
/*
* Copyright (C) NEC Electronics Corporation 2006
* NEC ELECTRONICS CONFIDENTIAL AND PROPRIETARY
* All rights reserved by NEC Electronics Corporation.
* This program must be used solely for the purpose for which
* it was furnished by NEC Electronics Corporation. No part of this
* program may be reproduced or disclosed to others, in any
* form, without the prior written permission of NEC Electronics
* Corporation. Use of copyright notice dose not evidence
* publication of the program.
*/
//-----------------------------------------------------------------------------
// #pragma directive for CC78K0
//-----------------------------------------------------------------------------
#pragma sfr
#pragma di
#pragma ei
#pragma interrupt INTKR isr_INTKR
#pragma interrupt INTTM51 isr_INTTM51
//-----------------------------------------------------------------------------
// Include files
//-----------------------------------------------------------------------------
#include "lcd.h"
#include "defines.h"
//#define uchar unsigned char
//-----------------------------------------------------------------------------
// Function prototyps
//-----------------------------------------------------------------------------
extern void RTC_init();
extern void Rtc();
extern void Remocon_init();
extern void Remocon();
extern void RemoconTime();
extern void RemoconKeyOff();
extern void TIMER_init();
extern void KitchenTimer();
extern void VoltMeter();
extern void SelfVoltMeter();
extern void Temprature();
extern void Buzzer();
extern void alarm();
//unsigned char i;
//extern void alarm();
//extern void alarm();
//-----------------------------------------------------------------------------
// Extern variables/constants
//-----------------------------------------------------------------------------
extern volatile unsigned char cRemCode; // Remocon code
//-----------------------------------------------------------------------------
// Local constants
//-----------------------------------------------------------------------------
// figure:43210
static const char s_clock[] ="CLOCK";
static const char s_timer[] ="KITCHEN TIMER ";
static const char s_temp[] ="TEMP ";
static const char s_voltmeter[] ="VOLT METER ";
static const char s_selfmeter[] ="SELF VOLT METER ";
static const char s_remo[] ="REMOCON ";
static const char s_buz[] ="BUZZER ";
// for Openning
static const char s_openning[] =" NEC 78K0/Lx3 ALL Flash Microcomputer ";
//-----------------------------------------------------------------------------
// Global variables
//-----------------------------------------------------------------------------
volatile unsigned char sw3_in;
volatile unsigned char sw4_in;
unsigned char menu;
struct{
unsigned char s100;
unsigned char s10;
unsigned char s1;
}bcd;
//-----------------------------------------------------------------------------
// Module: BCD_calc
// Description: Calculate BCD values for LCD output
//-----------------------------------------------------------------------------
void BCD_calc(unsigned char data)
{
bcd.s100 = data / 100;
data = data % 100;
bcd.s10 = data / 10;
bcd.s1 = data % 10;
}
//-----------------------------------------------------------------------------
// Module name: WaitBase50ms
// Description: This module delays the program for (number * 50ms).
//-----------------------------------------------------------------------------
void WaitBase50ms(unsigned char number)
{
TMC52 = 0x00; // initialize Timer52
TCL52 = 0x07; // set input clock to fxp / 2^12 = 1.95kHz @ 8MHz => 0.522ms
CR52 = 98-1; // set interval time to 50 ms
TCE52 = 1; // start Timer52
while(number > 0 && TCE52==1) {
while(!TMIF52 && TCE52==1); // wait for Timer52 Interrupt request flag
TMIF52 = 0; // clear Timer52 interruupt request flag
number--;
}
TCE52 = 0; // stop Timer52
}
//-----------------------------------------------------------------------------
// Module name: WaitBase1ms
// Description: This module delays the program for (number * 1ms).
//-----------------------------------------------------------------------------
void WaitBase1ms(unsigned char number)
{
TMC52 = 0x00; // initialize Timer52
TCL52 = 0x05; // set input clock to fxp / 2^6 = 125kHz @ 8MHz => 8us
CR52 = 125-1; // set interval time to 1 ms
TCE52 = 1; // start Timer52
while(number > 0 && TCE52==1)
{
while(!TMIF52 && TCE52==1); // wait for Timer52 Interrupt request flag
TMIF52 = 0; // clear Timer52 interruupt request flag
number--;
}
TCE52 = 0; // stop Timer52
}
void Wait1ms()
{
// Initialization of timer
TMC51 = 0x00; // initialize Timer51
TCL51 = 0x05; // set input clock to fxp / 2^6 = 125kHz @ 8MHz => 8us
CR51 = 125-1; // set interval time to 1 ms
TCE51 = 1; // start Timer51
TMIF51 = 0;
TMMK51 = 0;
}
//-----------------------------------------------------------------------------
// Module: KeyOff
// Description: All Key Off
//-----------------------------------------------------------------------------
void AllKeyOff(void)
{
sw3_in=0;
RemoconKeyOff();
}
void inter()
{
if(sw3_in==0)
alarm();
}
void inte()
{
if(sw4_in==0)
Buzzer();
}
//-----------------------------------------------------------------------------
// Module: main
// Description: main module
//-----------------------------------------------------------------------------
/*void alarm(void)
{
PM3.4=0; // output mode
play(&alarm_song[0]);
TMC00 = 0x00; // stop Timer01
TOC00 = 0x09; // timer output set
}*/
void main(void)
{
DI(); // disable all interrupts
// Initialization of clock
OSCCTL = 0xd0; // external clock input mode
PCC = 0x00; // CPU clock = fxp
MCM = 0x00; // Set main system clock and peripheral hardware clock
OSTS = 0x05; // Set minimum oscillation stabilization time
// Initialization of a use port
PM4 = 0x7e; // port input setting P46-42:KR6-2,P41:RIN
PU4 = 0x7C; // enable Pull-up resistor//昻悗珛嚋
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -