您当前的位置:五五电子网电子知识单片机-工控设备AVR单片机PC键盘与AVR单片机连接的C语言源程序 正文
PC键盘与AVR单片机连接的C语言源程序

PC键盘与AVR单片机连接的C语言源程序

点击数:7883 次   录入时间:03-04 11:45:20   整理:http://www.55dianzi.com   AVR单片机
0x24,'E',
0x25,'?,
0x26,'#',
0x29,' ',
0x2a,'V',
0x2b,'F',
0x2c,'T',
0x2d,'R',
0x2e,'%',
0x31,'N',
0x32,'B',
0x33,'H',
0x34,'G',
0x35,'Y',
0x36,'&',
0x39,'L',
0x3a,'M',
0x3b,'J',
0x3c,'U',
0x3d,'/',
0x3e,'(',
0x41,';',
0x42,'K',
0x43,'I',
0x44,'O',
0x45,'=',
0x46,')',
0x49,':',
0x4a,'_',
0x4b,'L',
0x4c,'?,
0x4d,'P',
0x4e,'?',
0x52,'?,
0x54,'?,
0x55,'`',
0x5a,13,
0x5b,'^',
0x5d,'*',
0x61,'>',
0x66,8,
0x69,'1',
0x6b,'4',
0x6c,'7',
0x70,'0',
0x71,',',
0x72,'2',
0x73,'5',
0x74,'6',
0x75,'8',
0x79,'+',
0x7a,'3',
0x7b,'-',
0x7c,'*',
0x7d,'9',
0,0
};

main.c

/********************************************
Chip type           : AT90S4434
Clock Frequency     : 8,000000 MHz
Memory model        : Tiny
Internal SRAM size  : 256
External SRAM size  : 0
Data Stack size     : 64
*********************************************/

#include <90s4434.h>
#include "kb.h"
#include <delay.h>  


// Alphanumeric LCD Module functions
#asm
   .equ __lcd_port=0x15
#endasm
#include <lcd.h>

// Declare your global variables here

void main(void)
{

// Declare your local variables here
    unsigned char key;

// Input/Output Ports initialization
// Port A
PORTA=0x00;
DDRA=0x00;

// Port B
PORTB=0x00;
DDRB=0x00;

// Port C
PORTC=0x00;
DDRC=0x00;

// Port D
PORTD=0x00;
DDRD=0x00;

// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: Timer 0 Stopped
// Mode: Output Compare
// OC0 output: Disconnected
TCCR0=0x00;
TCNT0=0x00;

// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: Timer 1 Stopped
// Mode: Output Compare
// OC1A output: Discon.
// OC1B output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
TCCR1A=0x00;
TCCR1B=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;

// Timer/Counter 2 initialization
// Clock source: System Clock
// Clock value: Timer 2 Stopped
// Mode: Output Compare
// OC2 output: Disconnected
TCCR2=0x00;
ASSR=0x00;
TCNT2=0x00;
OCR2=0x00;

// External Interrupt(s) initialization
// INT0: Oon
// INT1: Off
GIMSK= 0x40;        // Enable INT0 interrupt
MCUCR=0x00;

// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x00;

// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0x80;

// LCD module initialization
//lcd_init(20);            // Init 20 Zeichendisplay
 lcd_init(16);         // Init 16 Zeichendisplay

 InitKeyBoard();               // Initialize keyboard reception
 
 while(1)
    {
        key = getchar_kb();
        lcd_putchar(key);
        delay_ms(5);  
     
    }

}



上一页  [1] [2] [3] 


本文关键字:单片机  源程序  键盘  C语言  AVR单片机单片机-工控设备 - AVR单片机

《PC键盘与AVR单片机连接的C语言源程序》相关文章>>>