/*
* File: sw_Lcd.c
* Author: PhanHoangThinh
*
* Created on Ngày 26 tháng 6 n?m 2017, 20:46
*/
#include <xc.h>
#include <htc.h>
#include <stdio.h>
#include <stdlib.h>
#include "lcd.h"
#define _XTAL_FREQ 4000000
// CONFIG1
#pragma config FOSC = HS // Oscillator Selection bits (HS oscillator: High-speed crystal/resonator on RA6/OSC2/CLKOUT and RA7/OSC1/CLKIN)
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled and can be enabled by SWDTEN bit of the WDTCON register)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config MCLRE = ON // RE3/MCLR pin function select bit (RE3/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 = OFF // Brown Out Reset Selection bits (BOR disabled)
#pragma config IESO = OFF // Internal External Switchover bit (Internal/External Switchover mode is disabled)
#pragma config FCMEN = OFF // Fail-Safe Clock Monitor Enabled bit (Fail-Safe Clock Monitor is disabled)
#pragma config LVP = OFF // Low Voltage Programming Enable bit (RB3 pin has digital I/O, HV on MCLR must be used for programming)
// CONFIG2
#pragma config BOR4V = BOR40V // Brown-out Reset Selection bit (Brown-out Reset set to 4.0V)
#pragma config WRT = OFF // Flash Program Memory Self Write Enable bits (Write protection off)
// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.
unsigned int num1,num2,num3;
void main(void)
{
ANSEL=0x00;
ANSELH=0x00;
TRISBbits.TRISB1=1;
TRISBbits.TRISB2=1;
TRISBbits.TRISB3=1;
// char s[10];
lcd_init();
num1=00;
num2=00;
num3=00;
lcd_gotoxy(4,1);
printf("%02d-%02d-%02d",num1,num2,num3);
while(1)
{
lcd_gotoxy(1,0);
lcd_puts(" DIGITAL CLOCK");
if(RB1==0)
{
__delay_ms(100);
while(RB1==0)
{
__delay_ms(100);
lcd_gotoxy(4,1);
num1++;
printf("%02d",num1);
lcd_gotoxy(6,1);
lcd_puts("-");
if(num1==99)
{
num1=0;
}
}
}
if(RB2==0)
{
__delay_ms(100);
while(RB2==0)
{
__delay_ms(100);
lcd_gotoxy(7,1);
num2++;
printf("%02d",num2);
lcd_gotoxy(9,1);
lcd_puts("-");
if(num2==99)
{
num2=0;
}
}
}
if(RB3==0)
{
__delay_ms(100);
while(RB3==0)
{
__delay_ms(100);
lcd_gotoxy(10,1);
num3++;
printf("%02d",num3);
if(num3==99)
{
num3=0;
}
}
}
}
}
Blog trao đổi tài liệu học tập và làm việc. Thông tin hỗ trợ kĩ thuật phanhoangthinhhg@gmail.com
Next
« Prev Post
« Prev Post
Previous
Next Post »
Next Post »
Đăng ký:
Đăng Nhận xét (Atom)
1 comments:
commentsmikro C s thịnh?
Reply