嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 10 元微信扫码支付:10 元
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
PIC16F877A 学习例程
/******************************************************************************
* 函数名: 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