📄 main.c
字号:
/**************************************************************************/
/**MITSUBISHI**MITSUBISHI**MITSUBISHI**MITSUBISHI**MITSUBISHI**MITSUBISHI**/
/**************************************************************************/
/**************************************************************************/
/* DISCLAIMER: */
/* We (MITSUBISHI ELECTRIC B.V.) do not warrant that the Software is */
/* free from claims by a third party of copyright, patent, trademark, */
/* trade secret or any other intellectual property infringement. */
/* */
/* Under no circumstances are we liable for any of the following: */
/* */
/* 1. third-party claims against you for losses or damages; */
/* 2. loss of, or damage to, your records or data; or */
/* 3. economic consequential damages (including lost profits or */
/* savings) or incidental damages, even if we are informed of */
/* their possibility. */
/* */
/* We do not warrant uninterrupted or error free operation of the */
/* Software. We have no obligation to provide service, defect */
/* correction, or any maintenance for the Software. We have no */
/* obligation to supply any Software updates or enhancements to you */
/* even if such are or later become available. */
/* */
/* IF YOU DOWNLOAD OR USE THIS SOFTWARE YOU AGREE TO THESE TERMS. */
/* */
/* THERE ARE NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING THE */
/* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
/* PARTICULAR PURPOSE. */
/**************************************************************************/
/**************************************************************************/
/* */
/* */
/* Name: MAIN.C */
/* Date : 12.02.99 */
/* Author: CA */
/* Change: */
/* (Date) (Author) (Description) */
/* */
/**************************************************************************/
#define public extern
#include <intrm16c.h>
#include "sfr_3061.h"
#include "init.h"
#include "timer_a.h"
#include "sys.h"
#include "general.h"
#undef public
// global variables
// Main routine
void main (void)
{
unsigned char buf;
unsigned int i;
unsigned int ms;
ms = 0;
// disable_interrupt();
// init I/O Ports and special function register
init_port(); // initialize Port 0 to Port 10
// init_reg(); // initialize Special Function Register
// init processor mode and system clock frequency
// processor_mode_set(); // set single-chip mode
// system_clock_set(); // no division mode
nop_instruction(); // for nothing
// initialize variables
timer_100ms = 0;
state_lcd = STATE_LCD_OFF;
// initialize peripherals
timer_a0_init_timer_mode(); /* fxin/32 */
timer_a0_set(16000); /* underflow after 100ms at 10MHz */
timer_a0_start();
timer_a0_interrupt_set();
timer_a1_init_timer_mode(); /* fxin/32 */
timer_a1_set(800); /* underflow after 2ms at 10MHz */
timer_a1_interrupt_set();
timer_a1_start();
i=0;
TIME_ON = 950;
TIME_OFF = 600;
enable_interrupt();
// start of main loop switch polling (play, record, off)
// Until STATE_LCD_18 movement of the string "CONTROL LCD" is simulated.
// Then string "WITH" in displayed.
// After this the string "M16C" is flashing a few times.
// Then some number sequences are displayed (look case STAGE_LCD_25).
for (;;)
{
// 1 second over
if(timer_100ms>=10) // timer_100ms is incremented in timer A0 interrupt
{
timer_100ms=0;
// Every second new initialisation of the digits.
// After a case statement ist passed "state_lcd" is incremented
switch(state_lcd)
{
case STATE_LCD_OFF: // -------- all digits are off
lcd_1 = LCD_OFF;
lcd_2 = LCD_OFF;
lcd_3 = LCD_OFF;
lcd_4 = LCD_OFF;
lcd_5 = LCD_OFF;
lcd_6 = LCD_OFF;
lcd_7 = LCD_OFF;
lcd_8 = LCD_OFF;
state_lcd = STATE_LCD_1; // next sequence-state is initialised
break;
case STATE_LCD_1: // -------C is displayed
lcd_1 = LCD_OFF;
lcd_2 = LCD_OFF;
lcd_3 = LCD_OFF;
lcd_4 = LCD_OFF;
lcd_5 = LCD_OFF;
lcd_6 = LCD_OFF;
lcd_7 = LCD_OFF;
lcd_8 = LCD_C;
state_lcd = STATE_LCD_2; // next sequence-state is initialised
break;
case STATE_LCD_2: // ------CO is initialised
lcd_1 = LCD_OFF;
lcd_2 = LCD_OFF;
lcd_3 = LCD_OFF;
lcd_4 = LCD_OFF;
lcd_5 = LCD_OFF;
lcd_6 = LCD_OFF;
lcd_7 = LCD_C;
lcd_8 = LCD_O;
state_lcd = STATE_LCD_3; // next sequence-state is initialised
break;
case STATE_LCD_3: // -----CON is initialised
lcd_1 = LCD_OFF;
lcd_2 = LCD_OFF;
lcd_3 = LCD_OFF;
lcd_4 = LCD_OFF;
lcd_5 = LCD_OFF;
lcd_6 = LCD_C;
lcd_7 = LCD_O;
lcd_8 = LCD_N;
state_lcd = STATE_LCD_4; // next sequence-state is initialised
break;
case STATE_LCD_4: // ----CONT is initialised
lcd_1 = LCD_OFF;
lcd_2 = LCD_OFF;
lcd_3 = LCD_OFF;
lcd_4 = LCD_OFF;
lcd_5 = LCD_C;
lcd_6 = LCD_O;
lcd_7 = LCD_N;
lcd_8 = LCD_T;
state_lcd = STATE_LCD_5; // next sequence-state is initialised
break;
case STATE_LCD_5: // ---CONTR is initialised
lcd_1 = LCD_OFF;
lcd_2 = LCD_OFF;
lcd_3 = LCD_OFF;
lcd_4 = LCD_C;
lcd_5 = LCD_O;
lcd_6 = LCD_N;
lcd_7 = LCD_T;
lcd_8 = LCD_R;
state_lcd = STATE_LCD_6; // next sequence-state is initialised
break;
case STATE_LCD_6: // --CONTRO is initialised
lcd_1 = LCD_OFF;
lcd_2 = LCD_OFF;
lcd_3 = LCD_C;
lcd_4 = LCD_O;
lcd_5 = LCD_N;
lcd_6 = LCD_T;
lcd_7 = LCD_R;
lcd_8 = LCD_O;
state_lcd = STATE_LCD_7; // next sequence-state is initialised
break;
case STATE_LCD_7: // -CONTROL is initialised
lcd_1 = LCD_OFF;
lcd_2 = LCD_C;
lcd_3 = LCD_O;
lcd_4 = LCD_N;
lcd_5 = LCD_T;
lcd_6 = LCD_R;
lcd_7 = LCD_O;
lcd_8 = LCD_L;
state_lcd = STATE_LCD_8; // next sequence-state is initialised
break;
case STATE_LCD_8: // CONTROL- is initialised
lcd_1 = LCD_C;
lcd_2 = LCD_O;
lcd_3 = LCD_N;
lcd_4 = LCD_T;
lcd_5 = LCD_R;
lcd_6 = LCD_O;
lcd_7 = LCD_L;
lcd_8 = LCD_OFF;
state_lcd = STATE_LCD_9; // next sequence-state is initialised
break;
case STATE_LCD_9: // ONTROL-L is initialised
lcd_1 = LCD_O;
lcd_2 = LCD_N;
lcd_3 = LCD_T;
lcd_4 = LCD_R;
lcd_5 = LCD_O;
lcd_6 = LCD_L;
lcd_7 = LCD_OFF;
lcd_8 = LCD_L;
state_lcd = STATE_LCD_10; // next sequence-state is initialised
break;
case STATE_LCD_10: // NTROL-LC is initialised
lcd_1 = LCD_N;
lcd_2 = LCD_T;
lcd_3 = LCD_R;
lcd_4 = LCD_O;
lcd_5 = LCD_L;
lcd_6 = LCD_OFF;
lcd_7 = LCD_L;
lcd_8 = LCD_C;
state_lcd = STATE_LCD_11; // next sequence-state is initialised
break;
case STATE_LCD_11: // TROL-LCD is initialised
lcd_1 = LCD_T;
lcd_2 = LCD_R;
lcd_3 = LCD_O;
lcd_4 = LCD_L;
lcd_5 = LCD_OFF;
lcd_6 = LCD_L;
lcd_7 = LCD_C;
lcd_8 = LCD_D;
state_lcd = STATE_LCD_12; // next sequence-state is initialised
break;
case STATE_LCD_12: // ROL-LCD- is initialised
lcd_1 = LCD_R;
lcd_2 = LCD_O;
lcd_3 = LCD_L;
lcd_4 = LCD_OFF;
lcd_5 = LCD_L;
lcd_6 = LCD_C;
lcd_7 = LCD_D;
lcd_8 = LCD_OFF;
state_lcd = STATE_LCD_13; // next sequence-state is initialised
break;
case STATE_LCD_13: // OL-LCD-- is initialised
lcd_1 = LCD_O;
lcd_2 = LCD_L;
lcd_3 = LCD_OFF;
lcd_4 = LCD_L;
lcd_5 = LCD_C;
lcd_6 = LCD_D;
lcd_7 = LCD_OFF;
lcd_8 = LCD_OFF;
state_lcd = STATE_LCD_14; // next sequence-state is initialised
break;
case STATE_LCD_14: // L-LCD--- is initialised
lcd_1 = LCD_L;
lcd_2 = LCD_OFF;
lcd_3 = LCD_L;
lcd_4 = LCD_C;
lcd_5 = LCD_D;
lcd_6 = LCD_OFF;
lcd_7 = LCD_OFF;
lcd_8 = LCD_OFF;
state_lcd = STATE_LCD_15; // next sequence-state is initialised
break;
case STATE_LCD_15: // -LCD---- is initialised
lcd_1 = LCD_OFF;
lcd_2 = LCD_L;
lcd_3 = LCD_C;
lcd_4 = LCD_D;
lcd_5 = LCD_OFF;
lcd_6 = LCD_OFF;
lcd_7 = LCD_OFF;
lcd_8 = LCD_OFF;
state_lcd = STATE_LCD_16; // next sequence-state is initialised
break;
case STATE_LCD_16: // LCD----- is initialised
lcd_1 = LCD_L;
lcd_2 = LCD_C;
lcd_3 = LCD_D;
lcd_4 = LCD_OFF;
lcd_5 = LCD_OFF;
lcd_6 = LCD_OFF;
lcd_7 = LCD_OFF;
lcd_8 = LCD_OFF;
state_lcd = STATE_LCD_17; // next sequence-state is initialised
break;
case STATE_LCD_17: // CD------ is initialised
lcd_1 = LCD_C;
lcd_2 = LCD_D;
lcd_3 = LCD_OFF;
lcd_4 = LCD_OFF;
lcd_5 = LCD_OFF;
lcd_6 = LCD_OFF;
lcd_7 = LCD_OFF;
lcd_8 = LCD_OFF;
state_lcd = STATE_LCD_18; // next sequence-state is initialised
break;
case STATE_LCD_18: // D------- is initialised
lcd_1 = LCD_D;
lcd_2 = LCD_OFF;
lcd_3 = LCD_OFF;
lcd_4 = LCD_OFF;
lcd_5 = LCD_OFF;
lcd_6 = LCD_OFF;
lcd_7 = LCD_OFF;
lcd_8 = LCD_OFF;
state_lcd = STATE_LCD_19; // next sequence-state is initialised
break;
case STATE_LCD_19: // all digits are off
lcd_1 = LCD_OFF;
lcd_2 = LCD_OFF;
lcd_3 = LCD_OFF;
lcd_4 = LCD_OFF;
lcd_5 = LCD_OFF;
lcd_6 = LCD_OFF;
lcd_7 = LCD_OFF;
lcd_8 = LCD_OFF;
state_lcd = STATE_LCD_20; // next sequence-state is initialised
break;
case STATE_LCD_20: // --WITH-- is initialised two times
lcd_1 = LCD_OFF;
lcd_2 = LCD_OFF;
lcd_3 = LCD_W;
lcd_4 = LCD_I;
lcd_5 = LCD_T;
lcd_6 = LCD_H;
lcd_7 = LCD_OFF;
lcd_8 = LCD_OFF;
if(i<2)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -