/////////////////read data parameter uchar LCD_DataRead(void) { //8080 mode uchar Data; TRISC = 0xFF; WR = 1; LCD_CS = 0; RS = 0; RD = 0; Delay1us(1); Data = PORTC; RD = 1; LCD_CS = 1; RS = 1; TRISC = 0x00; return Data; /* //6800 mode uchar reg_rddata; DATA_BUS = 0xff; cs =0; // chip enable. wr = 1; // rs = 0; // rd = 1; // rd = 0; reg_rddata = DATA_BUS; ; ; rd = 0; // rd = 1; cs =1; // chip disable. return(reg_rddata); */ }
uint8_t LCD1602_WaitBusy() { uint16_t timeout=0; Delay2ms(); LCD1602_RS_L; LCD1602_RW_H; Delay100us(); LCD1602_EN_H; while(LCD1602_DB7_READ)//缁涘绶�602鏉╂柨娲栨担搴f暩楠烇拷 { timeout++; Delay1us(); if(timeout>200) { LCD1602_EN_L; return 1;//Still Busy } } LCD1602_EN_L; return 0; }
void __ISR(_EXTERNAL_4_IRQ, ipl1) INT1_ISR(void){ if(INT_PIN){ mINT4SetEdgeMode(0); if (DIR_PIN) current++; else current--; }else{ mINT4SetEdgeMode(1); if (!DIR_PIN) current++; else current--; } Delay1us(3);//debounce mINT4ClearIntFlag(); }
///////////write data or parameter void LCD_DataWrite(unsigned char Data) {//8080 mode RD = 1; LCD_CS = 0; RS = 0; LATC = Data; WR = 0; Delay1us(1); WR = 1; LCD_CS = 1; LATC = 0xff; RS = 1; /* //6800 mode cs =0; // chip enable. wr = 0; // rs = 1; // rs = 0; DATA_BUS = Data; rd = 0; // ; ; rd = 0; // cs =1; // chip disable */ }
void LCD_CmdWrite(unsigned char Cmd) {//8080 mode RD = 1; LCD_CS = 0; RS = 1; LATC = Cmd; WR = 0; Delay1us(1); WR = 1; LCD_CS = 1; LATC = 0xff; RS = 0; /* //6800 mode cs =0; // chip enable. wr = 0; // rs = 1; // rs = 0; DATA_BUS = Cmd; rd = 1; // ; ; rd = 0; // cs =1; // chip disable. */ }
uint8_t SPITransceve(uint8_t b){ SpiChnPutC(2, b); // send data on the master channel, SPI1 Delay1us(10); return SpiChnGetC(2); // get the received data }