Hoàng Nhân Pro ● Forum
Welcome To Hoang Nhan Pro - Forum
Diễn Đàn Chia Sẻ, Tổng Hợp Kiến Thức Chuyên Nghành Điện Tử - Tin Học và Giải Trí, Nơi Giao Lưu, Chia Sẻ Kiến Thức, Kinh Nghiệm Học Tập Với Bạn Bè, Thế Giới Dành Cho Tuổi Teen...
Cảm ơn bạn đã ghé thăm Diễn đàn của Hoàng Nhân Pro
https://hoangnhanpro.forumvi.com

Join the forum, it's quick and easy

Hoàng Nhân Pro ● Forum
Welcome To Hoang Nhan Pro - Forum
Diễn Đàn Chia Sẻ, Tổng Hợp Kiến Thức Chuyên Nghành Điện Tử - Tin Học và Giải Trí, Nơi Giao Lưu, Chia Sẻ Kiến Thức, Kinh Nghiệm Học Tập Với Bạn Bè, Thế Giới Dành Cho Tuổi Teen...
Cảm ơn bạn đã ghé thăm Diễn đàn của Hoàng Nhân Pro
https://hoangnhanpro.forumvi.com
Hoàng Nhân Pro ● Forum
Bạn có muốn phản ứng với tin nhắn này? Vui lòng đăng ký diễn đàn trong một vài cú nhấp chuột hoặc đăng nhập để tiếp tục.
Tìm kiếm
 
 

Display results as :
 


Rechercher Advanced Search

Admin Support
Mobile: (84)1656593086

Yahoo:
yeu_em_vi_yeu_em
Latest topics
» Một Số Bài Tập Ví Dụ Về PIC 16f877a
Giao Tiếp DS1337 + PIC Viết bằng CCS (DEMO) Empty2nd March 2013, 22:37 by luuvu_01

» cFosSpeed 8.03 build 2010 - Đăng ký bằng key thành công
Giao Tiếp DS1337 + PIC Viết bằng CCS (DEMO) Empty21st January 2013, 15:25 by hoangnhanpro

» Share công cụ chỉnh sửa file MANIFEST.MF online
Giao Tiếp DS1337 + PIC Viết bằng CCS (DEMO) Empty8th January 2013, 13:35 by hoangnhanpro

» Share công cụ tạo Logo Team + Tết Online cực đẹp
Giao Tiếp DS1337 + PIC Viết bằng CCS (DEMO) Empty8th January 2013, 13:35 by hoangnhanpro

» [hot] SMS chúc mừng năm mới 2013, sms chuc nam moi, tin nhan chuc mung nam moi
Giao Tiếp DS1337 + PIC Viết bằng CCS (DEMO) Empty28th December 2012, 01:31 by hoangnhanpro

» Opera Mini Mod Pro v4.21.25 Hack Phone and No Hack Phone
Giao Tiếp DS1337 + PIC Viết bằng CCS (DEMO) Empty26th December 2012, 17:02 by hoangnhanpro

» [Hot] Những Bộ SMS Noel 2012 Cực Hot - SMS Xep Hinh Chuc Ngay Noel
Giao Tiếp DS1337 + PIC Viết bằng CCS (DEMO) Empty13th December 2012, 04:54 by hoangnhanpro

» KIS 2012-2013 TRIAL RESET (Easy) - Trial Reset KIS 2012-2013 dễ dàng nhất
Giao Tiếp DS1337 + PIC Viết bằng CCS (DEMO) Empty13th December 2012, 04:50 by hoangnhanpro

» [TESTED-002] Lịch vạn niên LCD (full code)
Giao Tiếp DS1337 + PIC Viết bằng CCS (DEMO) Empty13th December 2012, 04:38 by hoangnhanpro

» [TESTED-001] Điều khiển thiết bị điện qua máy tính
Giao Tiếp DS1337 + PIC Viết bằng CCS (DEMO) Empty13th December 2012, 04:34 by hoangnhanpro

» [Thông báo] Diễn đàn đang được cũng cố và sửa chữa lại các link bị lỗi....
Giao Tiếp DS1337 + PIC Viết bằng CCS (DEMO) Empty13th December 2012, 04:08 by hoangnhanpro

» Share Zip ảnh Hot Girl 185 Pic 31,6 MB + Link URL
Giao Tiếp DS1337 + PIC Viết bằng CCS (DEMO) Empty10th December 2012, 12:10 by hoangnhanpro

» Tuyển tập Girl xinh Kute - Part 18
Giao Tiếp DS1337 + PIC Viết bằng CCS (DEMO) Empty10th December 2012, 11:41 by hoangnhanpro

» [VIP] Đồ án [DA094] Lịch vạn niên hiển thị LCD
Giao Tiếp DS1337 + PIC Viết bằng CCS (DEMO) Empty25th November 2012, 19:38 by hoangnhanpro

» [VIP] Đồ án [DA093] Ứng dụng RF điều khiển Robot
Giao Tiếp DS1337 + PIC Viết bằng CCS (DEMO) Empty25th November 2012, 19:36 by hoangnhanpro

Advertising
[Ads]: game java
[Ads]: game sex
[Ads]: clip sex
[Ads]: truyen tinh yeu hay
Affiliates
free forum


Giao Tiếp DS1337 + PIC Viết bằng CCS (DEMO)

Go down

Giao Tiếp DS1337 + PIC Viết bằng CCS (DEMO) Empty Giao Tiếp DS1337 + PIC Viết bằng CCS (DEMO)

Bài gửi by hoangnhanpro 28th November 2011, 16:18

Dùng để tham khảo...
Code:
#include <16F877A.h>
#include <def_877a.h>
#FUSES NOWDT, HS, NOPUT, NOPROTECT, NODEBUG, NOBROWNOUT, NOLVP, NOCPD, NOWRT
#use delay(clock=20000000)
#use rs232(baud=4800,parity=N,xmit=PIN_C6,rcv=PIN_C7,bi ts=9)
#use i2c(Master,Slow,sda=PIN_C4,scl=PIN_C3)

int8 sec,min,hour,dow,date,month,year;
int8 const maled7[10] = {0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90 };
int8 so[13]; //sec,min,hour,dow,date,month,year
#bit key = 0x06.7
void display() {
int8 led1,led2,led3,led4,led5,led6,led7,led8,led9,led10 ,led11,led12;
int8 temp1,temp2;
i2c_start();
i2c_write(0xD0);
i2c_write(0x00); //set register pointer
I2C_start();
I2C_write(0xD1); /* write slave address + read */
sec = i2c_read(1); /* starts w/last address stored in register pointer */
min = i2c_read(1);
hour = i2c_read(1) & 0x3F;
dow = i2c_read(1);
date = i2c_read(1);
month = i2c_read(1) & 0x7F;
year = i2c_read(0);
i2c_stop();
led1=sec & 0x0F;
led2=(sec & 0xF0)>>4; //convert to BCD SEC
led3=min & 0x0F;
led4=(min & 0xF0)>>4; //convert to BCD MIN
led5=hour & 0x0F;
led6=(hour & 0xF0)>>4; //convert to BCD HOUR
led7=date & 0x0F;
led8=(date & 0xF0)>>4; //convert to BCD DATE
led9=month & 0x0F;
led10=(month & 0xF0)>>4; //convert to BCD MONTH
led11=year & 0x0F;
led12=(year & 0xF0)>>4; //convert to BCD YEAR
// Sec - Min - Hour
PortB=maled7[led1]; RD0=0;//LED1
delay_us(200); if(key) RC2=0;
RD0=1;
PortB=maled7[led2]; RD1=0; //LED2
delay_us(200); if(key) RC2=1;
RD1=1;
PortB=maled7[led3]; RD2=0;//Led3
delay_us(200); if(key) RC2=0;
RD2=1;
PortB=maled7[led4]; RD3=0;//led4
delay_us(200); if(key) RC2=1;
RD3=1;
PortB=maled7[led5]; RD4=0;//led5
delay_us(200); RD4=1;
PortB=maled7[led6]; RD5=0;//led6
delay_us(200); RD5=1;//*/
/*/ Date - Month - Year
PortB=maled7[led7]; RD0=0;//LED1
delay_us(200); RD0=1;
PortB=maled7[led8]; RD1=0; //LED2
delay_us(200); RD1=1;
PortB=maled7[led9]; RD2=0;//Led3
delay_us(200); RD2=1;
PortB=maled7[led10]; RD3=0;//led4
delay_us(200); RD3=1;
PortB=maled7[led11]; RD4=0;//led5
delay_us(200); RD4=1;
PortB=maled7[led12]; RD5=0;//led6
delay_us(200); RD5=1; */
}

void init_time() {
int8 date,mth,year,dow,hour,min,sec;
I2C_start(); /* The following Enables the Oscillator */
I2C_write(0xD0); /* address the part to write */
I2C_write(0x00); /* position the address pointer to 0 */
I2C_write(0); /* write 0 to the seconds register, clear the CH bit */
I2C_write(0x30); /* write slave address + write */
I2C_write(0x52); /* hour = 101 0010 12h mode - time =12 */
I2C_write(0x07); // Thoi gian ban dau la: 3/11/2005 - 12h/30ph/00sec
I2C_write(0x03);
I2C_write(0x11);
I2C_write(0x05);
I2C_stop();

I2C_start(); // Write control and status register
I2C_write(0xD0); // write slave address + write */
I2C_write(0x0e); // write register address, control register */
I2C_write(0x20); /* enable osc, bbsqi */
I2C_write(0x00);
I2C_stop();

}

void keyscan() {

}
void main() {
int8 temp;
int8 i;
#bit key = 0x08.7

setup_timer_0(RTCC_EXT_L_TO_H|RTCC_DIV_1);
set_timer0(0xC4);

TrisB=0x00;//output
TrisD=0x00;
TrisC=0x00;
trisc0=1; //Set key input pin
TMR0IF=0;
RC2=1;
if(key) {
init_time(); //Thiet lap thoi gian ban dau
sec=0;min=59;hour=19;
}
i2c_start();
i2c_write(0xD0);
i2c_write(0x00); //set register pointer
I2C_start();
I2C_write(0xD1); /* write slave address + read */
temp = i2c_read(1); /* starts w/last address stored in register pointer */
temp = i2c_read(1);
temp = i2c_read(1);
temp = i2c_read(1);
temp = i2c_read(1);
temp = i2c_read(1);
temp = i2c_read(0);
i2c_stop();

while(1) {
display();
}
}
(Sưu tầm)
hoangnhanpro
hoangnhanpro
Admin
Admin

Họ & Tên : Phạm Hoàng Nhân
Giới tính : Nam
Cung Hoàng Đạo : Taurus
Con Giáp : Goat
Tuổi (Age) : 32
Ngày Sinh (Birthday) : 17/05/1991
Ngày Gia Nhập : 04/10/2011
Đến Từ : Hoàng Nhân Pro
Sở Thích : Điện Tử - Tin Học
Công Việc : Đang Thất Nghiệp

Tổng số bài gửi : 575
Điểm (Point) : 6553
Danh Tiếng (Reputation) : 4


http://www.hoangnhanpro.forumvi.com

Về Đầu Trang Go down

Về Đầu Trang

- Similar topics

 
Permissions in this forum:
Bạn không có quyền trả lời bài viết