Trích:
Nguyên văn bởi goldstar09
Code ban co the kham khao trong phan vi du cua CCS. A cho minh hoi muon mua con nay o ha noi thi mua o dau vay ban? Minh tim mai chua duoc.
Thanks!!
|
hi.Ban co phan vi du do ko?gui cho minh voi.neu ban biet thi co the sua cho minh doan code nay nhe minh lam cung thay no thay doi nhung ko dung theo ly thuyet va hien gio no dang chay linh tinh.
#define MAX515_SDA PIN_C5
#define MAX515_SCLK PIN_C4
#use i2c(MASTER, scl=MAX515_sclk, sda=MAX515_Sda)
void out_max515(unsigned int16 v) {
// unsigned char fort,faible;
v<<=2;
// v>>8;
// faible=v&0b0000000011111111;
output_low(Pin_c3);
i2c_start();
i2c_write(0xD0); // Send the address of the device
i2c_write(0x00);
// i2c_start();
delay_us(100);
i2c_start();
i2c_write(v>>8);
i2c_write(v); // Send the data to the device
i2c_stop();
output_high(Pin_c3);
}
ban co the xem ho minh nhe.