资源简介
串口实验成功,发送成功返回发送数据,采用PIC16F690单片机,由于PIC 资源少,希望对大家有所帮助
代码片段和文件信息
/*
* File: main.c
* Author: sz
*
* Created on 2019?11?28? ??4:29
*/
#include
#include
#include
#pragma config FOSC = LP // Oscillator Selection bits (LP oscillator: Low-power crystal on RA4/OSC2/CLKOUT and RA5/OSC1/CLKIN)
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT enabled)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config MCLRE = ON // MCLR Pin Function Select bit (MCLR pin function is MCLR)
#pragma config CP = OFF // Code Protection bit (Program memory code protection is disabled)
#pragma config CPD = OFF // Data Code Protection bit (Data memory code protection is disabled)
#pragma config BOREN = ON // Brown-out Reset Selection bits (BOR enabled)
#pragma config IESO = ON // Internal External Switchover bit (Internal External Switchover mode is enabled)
#pragma config FCMEN = ON // Fail-Safe Clock Monitor Enabled bit (Fail-Safe Clock Monitor is enabled)
#include
#define uchar unsigned char
#define uint unsigned int
uint IntFlagintnum;
uint i;
bit Q=0;
unsigned char message[6];
unsigned char dat[6];
unsigned char j=0x00;
uint recdata[4]={0};
uint rectxdata[4]={0};
void init();
void w_eeprom(uchar ee_addruchar ee_data);
uchar r_eeprom(uchar ee_addr);
void delay(uint c)
{
uint ab;
for(a=c;a>0;a--)
for(b=110;b>0;b--);
}
void putch(unsigned char byte)//?????????
{
TXREG = byte;
while(TRMT==0)
{
asm(“nop“);
}
return;
}
void main()
{
uchar dat[6];
init();
w_eeprom(00xaa);
w_eeprom(10xca);
w_eeprom(20);
w_eeprom(30);
w_eeprom(40);
w_eeprom(50);
GIE = 1;
while(1)
{
if(Q==1)
{
Q=0;
putch(message[0]);
delay(500);
putch(message[1]);
delay(500);
putch(message[2]);
delay(500);
putch(message[3]);
delay(500);
putch(message[4]);
delay(500);
putch(message[5]);
w_eeprom(0message[0]);
w_eeprom(1message[1]);
w_eeprom(2message[2]);
w_eeprom(3message[3]);
w_eeprom(4message[4]);
w_eeprom(5message[5]);
delay(10);
dat[0] = r_eeprom(0);
dat[1] = r_eeprom(1);
dat[2] = r_eeprom(2);
dat[3] = r_eeprom(3);
dat[4] = r_eeprom(4);
dat[5] = r_eeprom(5);
GIE = 1;
}
putch(r_eeprom(0));
putch(r_eeprom(1));
putch(r_eeprom(2));
putch(r_eeprom(3));
putch(r_eeprom(4));
putch(r_eeprom(5));
delay(500);
}
}
void init()
{
OSCCON=0x65
- 上一篇:矩阵键盘堪称一绝的键盘扫描方法
- 下一篇:小las点云测试数据
评论
共有 条评论