em dùng mikroC for arm viết chương trình cho con LM3S8962 test cái lcd16x2. chỉ dùng cái sample code của nó, thay lại chỗ định nghĩa chân cẳng nhưng bị lỗi không dịch được, trong khi để như cũ thì ok.
em chỉ sửa đoạn này
thành thế này
Code:
// LCD module connections sbit LCD_RS at GPIO_PORTD_DATA.D7; sbit LCD_EN at GPIO_PORTD_DATA.D6; sbit LCD_D4 at GPIO_PORTD_DATA.D5; sbit LCD_D5 at GPIO_PORTD_DATA.D4; sbit LCD_D6 at GPIO_PORTB_DATA.B4; sbit LCD_D7 at GPIO_PORTB_DATA.B5; sbit LCD_RS_Direction at GPIO_PORTD_DIR.D7; sbit LCD_EN_Direction at GPIO_PORTD_DIR.D6; sbit LCD_D4_Direction at GPIO_PORTD_DIR.D5; sbit LCD_D5_Direction at GPIO_PORTD_DIR.D4; sbit LCD_D6_Direction at GPIO_PORTB_DIR.B4; sbit LCD_D7_Direction at GPIO_PORTB_DIR.B5; // End LCD module connections char txt1[] = "mikroElektronika"; char txt2[] = "Stellaris"; char txt3[] = "Lcd4bit"; char txt4[] = "example"; char i; // Loop variable void Move_Delay() { // Function used for text moving Delay_ms(750); // You can change the moving speed here } void main(){ Lcd_Init(); // Initialize LCD Lcd_Cmd(_LCD_CLEAR); // Clear display Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off Lcd_Out(1,6,txt3); // Write text in first row Lcd_Out(2,6,txt4); // Write text in second row Delay_ms(2000); Lcd_Cmd(_LCD_CLEAR); // Clear display Lcd_Out(1,1,txt1); // Write text in first row Lcd_Out(2,4,txt2); // Write text in second row Delay_ms(2000); // Moving text for(i=0; i<4; i++) { // Move text to the right 4 times Lcd_Cmd(_LCD_SHIFT_RIGHT); Move_Delay(); } while(1) { // Endless loop for(i=0; i<7; i++) { // Move text to the left 7 times Lcd_Cmd(_LCD_SHIFT_LEFT); Move_Delay(); } for(i=0; i<7; i++) { // Move text to the right 7 times Lcd_Cmd(_LCD_SHIFT_RIGHT); Move_Delay(); } } }
Code:
// LCD module connections sbit LCD_RS at GPIO_PORTA_DATA.B2; sbit LCD_EN at GPIO_PORTA_DATA.B3; sbit LCD_D4 at GPIO_PORTA_DATA.B4; sbit LCD_D5 at GPIO_PORTA_DATA.B5; sbit LCD_D6 at GPIO_PORTA_DATA.B6; sbit LCD_D7 at GPIO_PORTA_DATA.B7; sbit LCD_RS_Direction at GPIO_PORTA_DIR.B2; sbit LCD_EN_Direction at GPIO_PORTA_DIR.B3; sbit LCD_D4_Direction at GPIO_PORTA_DIR.B4; sbit LCD_D5_Direction at GPIO_PORTA_DIR.B5; sbit LCD_D6_Direction at GPIO_PORTA_DIR.B6; sbit LCD_D7_Direction at GPIO_PORTA_DIR.B7; // End LCD module connections
Code:
// LCD module connections sbit LCD_RS at GPIO_PORTD_DATA.D7; sbit LCD_EN at GPIO_PORTD_DATA.D6; sbit LCD_D4 at GPIO_PORTD_DATA.D5; sbit LCD_D5 at GPIO_PORTD_DATA.D4; sbit LCD_D6 at GPIO_PORTB_DATA.B4; sbit LCD_D7 at GPIO_PORTB_DATA.B5; sbit LCD_RS_Direction at GPIO_PORTD_DIR.D7; sbit LCD_EN_Direction at GPIO_PORTD_DIR.D6; sbit LCD_D4_Direction at GPIO_PORTD_DIR.D5; sbit LCD_D5_Direction at GPIO_PORTD_DIR.D4; sbit LCD_D6_Direction at GPIO_PORTB_DIR.B4; sbit LCD_D7_Direction at GPIO_PORTB_DIR.B5; // End LCD module connections
Comment