1.c

来自「AVR mega16双机通讯实验 从机接受数据并发送到lcd1602上显示」· C语言 代码 · 共 70 行

C
70
字号
#include < iom16v.h>
#include <macros.h>
#include "lcd1602.h"
unsigned char disp[] = {0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90};
void delayms(void)
{
char a;
for(a=0;a<141;a++)
;
}
void delay(int a)
{
int b;
for(b=0;b<a;b++)
delayms();
}
void Spi_init()
{
DDRB|=(1<<6);
SPCR=0xE3;
SPSR=0x00;
}

void main()
{
char *str="receive data :";

DDRA=0xFF;
PORTA=0x00;
DDRB=0xFF;
PORTB=0x00;
DDRC=0x00;
PORTC=0x00;
DDRD=0x00;
PORTD=0x00;


SEI();

Spi_init();

LCD_init();
LCD_write_str(0,0,str);



while(1);

}


#pragma interrupt_handler in:11
void in()
{
char temp[3];


temp[2]= (SPDR /100)%10+'0';
temp[1] = (SPDR /10) %10+'0';
temp[0] = (SPDR % 10)+'0';


LCD_write_char(11,1,temp[2]);

LCD_write_char(12,1,temp[1]);

LCD_write_char(13,1,temp[0]);

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?