otmp_vse-1
.docxМинистерство образования и науки Украины
Харьковский национальный университет радиоэлектроники
Кафедра телекоммуникационных систем
Отчеты
Дисциплина «Вычислительная техника и микропроцессоры»
Выполнила : Проверил:
Ст.гр.Тк-14-3 Филипенко О. И.
Бурейко.А.Ю
Харьков 2015
Лабораторная робота №1
-
Код программы #include <reg52.h> int main () { P1=0x55; return 0; }
-
Результат
Лабораторная робота №2
1.Код программы
#include<reg52.h> sbit LATCH_X = P3^5; sbit LATCH_Y = P2^0; unsigned char Ris[8] = {0x00, 0x00, 0x38, 0x3E, 0x38, 0xFF, 0xFF, 0x00}; void Delay(unsigned char t) { while(--t); } int main() { unsigned char adr = 0xFE; unsigned char i=0; P1 = Ris[i]; LATCH_X = 1; LATCH_Y = 0; if(adr & 0x80) { adr = adr « 1; adr |= 0x01; } else adr = adr « 1; i++; return 0; }
2.Результат
Лабораторная робота №3
1.Код программы
#include<reg52.h> sbit LATCH_X = P3^5; sbit LATCH_Y = P2^0; unsigned char Ris[8] = {0x00, 0x00, 0x38, 0x3E, 0x38, 0xFF, 0xFF, 0x00}; void Delay(unsigned char t) { while(--t); } int main() { unsigned char adr = 0xFE; unsigned char i=0; while (1) { P1 = 0xFF; LATCH_Y = 1; LATCH_Y = 0; P1 = Ris[i]; LATCH_X = 1; LATCH_X = 0; P1 = adr; LATCH_Y = 1; LATCH_Y = 0; if(adr & 0x80) { adr = adr « 1; adr |= 0x01; } else adr = adr « 1; i++; if(i == 8) i = 0; Delay(10000); } return 0;
2.Результат
Лабораторная робота №4
1.Код программы
#include <reg51.h> sbit LCD_EN=P2^2; sbit LCD_RS=P2^4; sbit LCD_WR=P2^3; #define DATA P1 void delayus2x(unsigned char t) { while (--t); } void delay (unsigned char t) { while(--t) { delayus2x(245); delayus2x(245); } } void lcdComand(unsigned char cmd) { LCD_RS=0; LCD_EN=1; DATA=cmd; delay(5); LCD_EN=0; } void lcdData(unsigned char dat) { LCD_RS=1; LCD_EN=1; DATA=dat; delay(5); LCD_EN=0; delay(10); } void clear (void) { lcdComand (0x01); delay(5); } void LCD_Init(void) { lcdComand(0x38); delay(5); lcdComand(0x38); delay(5); lcdComand(0x08); lcdComand(0x01); lcdComand(0x06); delay(5); lcdComand(0x0F); } void print (char*st) { while(*st != 0) { lcdData(*st); st++; } } int main() { LCD_WR = 0; LCD_Init(); clear(); print("Hello"); while(1); return 0; }
-
2.Решение
-
-
-
Лабораторная работа №5
-
-
Код программы
-
#include<reg52.h> #include"DS1302.h" #include<intrins.h> sbit RS = P2^4; sbit RW = P2^3; sbit EN = P2^2; sbit P20=P2^0; sbit P21=P2^1; sbit P35 = P3^5; #define DataPort P1 void DelayUs2x(unsigned char t) { while(--t); } void DelayMs(unsigned char t) { while(t--) { DelayUs2x(245); DelayUs2x(245); } } void LCD_Write_Com(unsigned char com) { RS = 0; RW = 0; EN = 1; DataPort = com; _nop_(); EN = 0; } void LCD_Write_Data(unsigned char Data) { RS = 1; RW = 0; EN = 1; DataPort = Data; _nop_(); EN = 0; } void LCD_Clear(void) { LCD_Write_Com(0x01); DelayMs(5); } void LCD_Init(void) { LCD_Write_Com(0x38); DelayMs(25); LCD_Write_Com(0x38); DelayMs(25); LCD_Write_Com(0x38); DelayMs(25); LCD_Write_Com(0x08); LCD_Write_Com(0x01); LCD_Write_Com(0x06); DelayMs(5); LCD_Write_Com(0x0F); } void LcdPrint(char* str) { LCD_Write_Com(0x80); DelayMs(5); while(*str != 0) { LCD_Write_Data (*str++); DelayMs(5); } } void main(void) { char buf[10] = "12:03"; P1=0x00; P20=0; P21=0; P35=0; P1=0xFF; LCD_Init(); LCD_Clear(); Ds1302_Init(); Ds1302_Write_Time(); while (1) { buf[0] = time_buf[4]/10 + 0x30; buf[1] = time_buf[4]%10 + 0x30; buf[3] = time_buf[5]/10 + 0x30; buf[4] = time_buf[5]%10 + 0x30; LcdPrint(buf); Ds1302_Read_Time(); DelayMs(500); } }
-
#include "ds1302.h" unsigned char time_buf1[8] = {20,10,6,5,12,55,00,6}; unsigned char time_buf[8] ; void Ds1302_Write_Byte(unsigned char addr, unsigned char d) { unsigned char i; RST_SET; addr = addr & 0xFE; for (i = 0; i < 8; i ++) { if (addr & 0x01) { IO_SET; } else { IO_CLR; } SCK_SET; SCK_CLR; addr = addr » 1; } for (i = 0; i < 8; i ++) { if (d & 0x01) { IO_SET; } else { IO_CLR; } SCK_SET; SCK_CLR; d = d » 1; } RST_CLR; } unsigned char Ds1302_Read_Byte(unsigned char addr) { unsigned char i; unsigned char temp; RST_SET; addr = addr | 0x01; for (i = 0; i < 8; i ++) { if (addr & 0x01) { IO_SET; } else { IO_CLR; } SCK_SET; SCK_CLR; addr = addr » 1; } for (i = 0; i < 8; i ++) { temp = temp » 1; if (IO_R) { temp |= 0x80; } else { temp &= 0x7F; } SCK_SET; SCK_CLR; } RST_CLR; return temp; } /*------------------------------------------------ ПтDS1302РґИлК±ЦУКэѕЭ ------------------------------------------------*/ void Ds1302_Write_Time(void) { unsigned char i,tmp; for(i=0;i<8;i++) { //BCD tmp=time_buf1[i]/10; time_buf[i]=time_buf1[i]%10; time_buf[i]=time_buf[i]+tmp*16; } Ds1302_Write_Byte(ds1302_control_add,0x00); Ds1302_Write_Byte(ds1302_sec_add,0x80); //Ds1302_Write_Byte(ds1302_charger_add,0xa9); Ds1302_Write_Byte(ds1302_year_add,time_buf[1]); Ds1302_Write_Byte(ds1302_month_add,time_buf[2]); Ds1302_Write_Byte(ds1302_date_add,time_buf[3]); Ds1302_Write_Byte(ds1302_day_add,time_buf[7]); Ds1302_Write_Byte(ds1302_hr_add,time_buf[4]); Ds1302_Write_Byte(ds1302_min_add,time_buf[5]); Ds1302_Write_Byte(ds1302_sec_add,time_buf[6]); Ds1302_Write_Byte(ds1302_day_add,time_buf[7]); Ds1302_Write_Byte(ds1302_control_add,0x80); } void Ds1302_Read_Time(void) { unsigned char i,tmp; time_buf[1]=Ds1302_Read_Byte(ds1302_year_add); time_buf[2]=Ds1302_Read_Byte(ds1302_month_add); time_buf[3]=Ds1302_Read_Byte(ds1302_date_add); time_buf[4]=Ds1302_Read_Byte(ds1302_hr_add); time_buf[5]=Ds1302_Read_Byte(ds1302_min_add); time_buf[6]=(Ds1302_Read_Byte(ds1302_sec_add))&0x7F; time_buf[7]=Ds1302_Read_Byte(ds1302_day_add); for(i=0;i<8;i++) { //BCD tmp=time_buf[i]/16; time_buf1[i]=time_buf[i]%16; time_buf1[i]=time_buf1[i]+tmp*10; } } /*------------------------------------------------ DS1302іхКј»Ї ------------------------------------------------*/ void Ds1302_Init(void) { RST_CLR; //RST SCK_CLR; //SCK Ds1302_Write_Byte(ds1302_sec_add,0x00); }
-
-
2.Решение
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-