实例介绍
【实例截图】

【核心代码】
/******************************************************************************
* 函数名: void main(void)
* 描述 : 主函数
* 输入 : none
* 输出 : none
******************************************************************************/
void main(void)
{
// 定时器0配置 - in RC mode
/* T0CS = 0X00; // Internal instruction cycle clock (CLKO)
PSA = 0X00; // Prescaler is assigned to the Timer0 module
PS0 = 0; // Prescaler Rate Select bits (1:1)
PS1 = 0;
PS2 = 0;
TMR0 = 232 ; // Timer0 Module Register (初值=256-定时时间/指令周期 14)预设定时为10us
TMR0IF =1; // TMR0 register has overflowed (must be cleared in software)
TMR0IE =1; // Enables the TMR0 interrupt
*/
// 定时器1配置
/* T1CKPS0 = 0; // 1:4 prescale value
T1CKPS1 = 1;
// T1OSCEN = 1; // Oscillator is enabled
TMR1CS = 0; // Internal clock (FOSC /4)
TMR1ON = 1; // Enables Timer1
TMR1 = 0xf63c; // 初值 = 65536 -(fose/4/分频值)*定时时间 预设定时为10ms
TMR1IF = 0; // TMR1 register overflowed (must be cleared in software)
TMR1IE =1; // Enables the TMR1 overflow interrupt
*/
// 串口通讯
/* TX9 = 0 ; // Selects 8-bit transmission
TXEN = 1; // Transmit enabled
SYNC = 0; // Asynchronous mode
BRGH = 1; // High speed (Asynchronous mode)
// SREN =1; // TBD
SPBRG = 0x0C ; // Baud Rate Generator Register 19200bps
ADDEN =0 ; // Disables address detection, all bytes are received and ninth bit can be used as parity bit
CREN = 1; // Enables continuous receive (Asynchronous mode)
RX9 = 0; // Selects 8-bit reception
SPEN = 1; // Serial port enabled
// (configures RC7/RX/DT and RC6/TX/CK pins as serial port pins)
// TXIE = 1; // 发送中断使能
RCIE =1; // 接收中断使能
*/
// SPI 初始化(master mode))
// init_SPI ();
// LED显示IO口
// TRISB =0; // RB 设置为输出端口
// ADCON1=0X07; // RA 设置为普通IO口
// 按键IO口
// TRISA0 = 1; // RA0 设置为输入 按键1
// TRISA1 = 1; // RA1 设置为输入 按键2
// TRISA2 = 1; // RA2 设置为输入 按键3
// 初始化串口通讯IO口
// TRISC6 =0; // RC6 TX 串口通讯 设置为输出
// TRISC7 =1; // RC7 RX 串口通讯 设置为输入
// cs_pin = 0; // 初始化CS
Init_ADC_Config(); // 初始化捕获配置
Init_ADC_PORT(); // RC2 作为输入捕获
// 中断使能
GIE = 1; // Enables all unmasked interrupts
PEIE = 1; // Enables all unmasked peripheral interrupts
// init_IIC();
init_1602LCD_PORT();
init_1602LCD();
__delay_ms(100);
// TRISA1 = 0 ;
// TRISA4 = 0;
// TRISA5 = 0;
while(1)
{
// Read_Battery_Paramater();
// RA0 =1;
// RA0 =0;
// __delay_ms(50);
// RA0 =1;
ultoa(str,Get_ADC_Value(Channe_0,0X0A),10); // 将参数转换成10进制ASCII字码
write_comm_1602LCD(0x01); // 1. 数据指针清零 2. 所有显示清零
__delay_us(500);
write_string_1602LCD(str,1,0);
/* ultoa(str,Log_Data[1],10); // 将参数转换成10进制ASCII字码
write_string_1602LCD(str,2,0);
Buuffer= Log_Data[1] - Log_Data[0];
ultoa(str,Buuffer,10); // 将参数转换成10进制ASCII字码
write_string_1602LCD(str,1,10);
ultoa(str,count,10); // 将参数转换成10进制ASCII字码
write_string_1602LCD(str,2,10);
*/
// ultoa(str,Reg.BatteryStatus,16); // 将参数转换成10进制ASCII字码
// write_string_1602LCD(str,2,10);
__delay_ms(1000);
// keypad_state1(); // 测试LED和按键
// keypad_state2();
// display_led();
// keypad_state3();
}
}
.
├── PIC16F877A 学习例程
│ └── Test_SYS.X
│ ├── 1602_LCD.h
│ ├── 24LC01B_HW.h
│ ├── 24LC01B_SW.h
│ ├── 93LC46B_HW.h
│ ├── 93LC46B_SW.h
│ ├── ADC_Get.h
│ ├── Capture_Mode.h
│ ├── Compare_Mode.h
│ ├── DS18B20_SW.h
│ ├── DS2438_ SW.h
│ ├── DS2784_ SW.h
│ ├── HDQ_SW.h
│ ├── Makefile
│ ├── PIC877A.pdf
│ ├── PWM_Mode.h
│ ├── build
│ │ └── default
│ │ └── production
│ │ ├── main.p1
│ │ ├── main.p1.d
│ │ └── main.pre
│ ├── common.h
│ ├── dist
│ │ └── default
│ │ └── production
│ │ ├── Test_SYS.X.production.cmf
│ │ ├── Test_SYS.X.production.elf
│ │ ├── Test_SYS.X.production.hex
│ │ ├── Test_SYS.X.production.hxl
│ │ ├── Test_SYS.X.production.lst
│ │ ├── Test_SYS.X.production.map
│ │ ├── Test_SYS.X.production.mum
│ │ ├── Test_SYS.X.production.obj
│ │ ├── Test_SYS.X.production.rlf
│ │ ├── Test_SYS.X.production.sdb
│ │ ├── Test_SYS.X.production.sym
│ │ └── memoryfile.xml
│ ├── main.c
│ └── nbproject
│ ├── Makefile-default.mk
│ ├── Makefile-genesis.properties
│ ├── Makefile-impl.mk
│ ├── Makefile-local-default.mk
│ ├── Makefile-variables.mk
│ ├── Package-default.bash
│ ├── configurations.xml
│ ├── private
│ │ ├── configurations.xml
│ │ └── private.xml
│ └── project.xml
└── 好例子网_PIC16F877A 学习例程.zip
10 directories, 43 files
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论