![]() |
![]() |
#4 |
Nhập môn đệ tử
Tham gia ngày: Nov 2011
Bài gửi: 5
: |
mình cũng đang làm đồ án ,mình rất muốn tham khảo code của bạn,bạn có thể gửi cho mình tam khảo được chứ,mail của mình la ''thanhtrungkhongcogikho@yahoo.com.vn ''nhe.
thank bạn nhiều. SẴN ĐÂY MÌNH MUỐN NHỜ BẠN,XEM HỘ MÌNH ĐOAẠN CODE SAU ĐƯƠC KO AH,MÌNH ĐỌC MẠI MÀ CHƯA HIỂU LẮM void read_ds1307() { i2c_start(); //Goi bit star tu master toi slave i2c_write(0xD0); //Gui dia chi cua slave,thiet lap chdo truyen d_lieu vao ds1307 i2c_write(0x01); //thiet lap vi tri con tro - set register pointer i2c_stop(); // Goi bit stop thu master toi slave i2C_start(); i2C_write(0xD1); //gui lenh doc du lieu sec=i2c_read(1); //Bat dau doc du lieu tu vi tri Con tro,Doc sec min=i2c_read(1); hour=i2c_read(1); //che do gio la 12h. Loai bo bit5 va bit6 dung lenh AND dow=i2c_read(1); //bit5=AM/PM date=i2c_read(1); //bit6=12/24 month=i2c_read(1); year=i2c_read(1); thu=i2c_read(0);//so(0)la de VDK biet YEAR la d_lieu cuoi i2c_stop(); //(2) //----------------------------------------Chuyen BCD sang Nhi Phan--------------------------------------- sec1=sec&0x0F; sec2=(sec&0x70)>>4; min1=min&0x0F; min2=(min&0x70)>>4; hour1=hour&0x0F; hour2=(hour&0x30)>>4; date1=date&0x0F; date2=(date&0x30)>>4; month1=month&0x0F; month2=(month&0x10)>>4; year1=year&0x0F; year2=(year&0xF0)>>4; } CHỖ ĐOẠN DỊCH 4 BÍT ĐÓ BẠN,DỊCH ĐỂ LÀM GÌ VẬY,CÁC GIÁ TRỊ NHƯ 0X0F,0X70,0X30 LẤY Ở ĐÂU RA VẬY AH,RẤT MONG NHẬN ĐƯỢC SỰ GIÚP ĐỠ CỦA MỌI NGƯỜI. THANK |
![]() |
![]() |
|
|