📄 595_1602_example.c
字号:
/********************************************************
* 程序说明:串行1602调试程序 *
* 版本: v1.0 *
* 平台: ATMega8L 8M *
* 作者: 傻孩子 *
* 日期: 2006年1月11日 *
* 修改: 傻孩子 *
* 修改日期:2006年2月19日 *
* *
* [说明] *
********************************************************/
# include "RD_ATMega8L.h"
/***********************
* 系 统 宏 定 义 *
***********************/
# pragma interrupt_handler Timer0OvfIsr:10
/*---------------------*
* SerialToCollateral.h *
* 配置宏定义 *
*---------------------*/
# define VSCK _PC4
# define VRCK _PC3
# define VSI _PC5
/*--- 定义_Use_8Bit_VitualPORT 选择单个595模式 ---*/
# define _Use_8Bit_VitualPORT
# include "SerialToCollateral.h"
/*---------------------*
* RD_LCD1602B.h *
* 配置宏定义 *
*---------------------*/
# define LCD_RS PV4
# define LCD_E PV5
# define LCD_SendHalfCharLow(a) VPORT &= 0xf0;VPORT |= (a & 0x0f);refreshVirtualPORT();
# define LCD_SendHalfCharHigh(a) VPORT &= 0xf0;VPORT |= (a >> 4);refreshVirtualPORT();
# define SetEnable LCD_E = High;refreshVirtualPORT();
# define SetDisable LCD_E = Low;refreshVirtualPORT();
/*--- 修改FlashTimeOut来修改显示字符闪烁的频率 ---*/
# define FlashTimeOut 800
# define RunStringSpeed 11
/*--- 定义_Use_LCD1602B_Serial 选择595串行连接模式(否则为直接连接模式) ---*/
# define _Use_LCD1602B_Serial
# include "RD_LCD1602B.h"
/***********************
* 全局变量声明区 *
***********************/
unsigned int FlashGIFStringCounter = 0;
unsigned int FlashTimeCounter = 0;
/***********************
* 系统函数声明区 *
***********************/
void SystemInit(void);
void PortInit(void);
void Timer0Init(void);
/********************************************************
* 函数说明:端口初始化 *
********************************************************/
void PortInit(void)
{
DDRC = 0xff;
PORTC = 0xff;
PORTDefine();
}
/********************************************************
* 函数说明:定时器0初始化函数 *
********************************************************/
void Timer0Init(void)
{
TCCR0 = 0x00; //stop
TCNT0 = 0x83; //set count
TCCR0 = 0x03; //start timer
}
/********************************************************
* 函数说明:定时器0中断处理函数 *
********************************************************/
void Timer0OvfIsr(void)
{
TCNT0 = 0x83;
FlashGIFStringCounter ++;
FlashTimeCounter ++;
}
/********************************************************
* 函数说明:系统初始化函数 *
********************************************************/
void SystemInit(void)
{
CLI();
PortInit();
Timer0Init();
LCDInit();
TIMSK = 0x01
SEI();
}
void main(void)
{
SystemInit();
while(1)
{
RunString("I really like this game! SWUST Roboteam ",1,1,1,16);
Flash("Hello AVR World!",' ',1,2);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -