![]() |
|
Tài trợ cho PIC Vietnam |
dsPIC - Bộ điều khiển tín hiệu số 16-bit Theo dự kiến của Microchip, vào khoảng năm 2011 dsPIC sẽ có doanh số lớn hơn PIC |
![]() |
|
Ðiều Chỉnh | Xếp Bài |
|
![]() |
#1 |
Đệ tử 3 túi
Tham gia ngày: Apr 2006
Bài gửi: 54
: |
Cho mình hỏi
Code:
/* defines for segment data transfer direction */ #define SEG1_50_SEG51_100 0x39 /* SEG1->SEG50 ,SEG51->SEG100 */ #define SEG1_50_SEG100_51 0x3d /* SEG1->SEG50 ,SEG100->SEG51 */ #define SEG100_51_SEG50_1 0x3b /* SEG100->SEG51,SEG50->SEG1 */ #define SEG100_51_SEG1_50 0x3f /* SEG100->SEG51,SEG1->SEG50 */ /* defines for COM data transfer direction */ #define COM1_COM16 0x3e /* Data transfer direction is COM1 to COM16 */ #define COM16_COM1 0x3f /* Data transfer direction is COM16 to COM1 */ Mình sửa file xlcd.h để giao tiếp 4 bit với LCD như này Code:
/********************************************************************/ /* Header for XLCD module library functions for */ /* P-tec PCOG1602B LCD controller */ /********************************************************************/ #if defined(__dsPIC30F__) #include <p30fxxxx.h> #elif defined(__dsPIC33F__) #include <p33Fxxxx.h> #elif defined(__PIC24H__) #include <p24Hxxxx.h> #endif #ifndef _XLCD_H #define _XLCD_H /* Comment out the following line if 4-bit interface is being used */ #define EIGHT_BIT_INTERFACE /* #defines of the data pins and the corresponding tris pins */ /* The READ_PIN_X #defines must match the corresponding DATA_PIN_X defines */ #define DATA_PIN_7 LATDbits.LATD3 #define DATA_PIN_6 LATDbits.LATD1 #define DATA_PIN_5 LATEbits.LATE8 #define DATA_PIN_4 LATCbits.LATC14 #define READ_PIN_7 PORTDbits.RD3 #define READ_PIN_6 PORTDbits.RD1 #define READ_PIN_5 PORTEbits.RE8 #define READ_PIN_4 PORTCbits.RC14 #define TRIS_DATA_PIN_7 TRISDbits.TRISD3 #define TRIS_DATA_PIN_6 TRISDbits.TRISD1 #define TRIS_DATA_PIN_5 TRISEbits.TRISE8 #define TRIS_DATA_PIN_4 TRISCbits.TRISC14 /* #defines of the control pins and the corresponding tris pins for 30F */ #define E_PIN LATCbits.LATC13 /* PORT for E */ #define RW_PIN LATBbits.LATB8 /* PORT for RW */ #define RS_PIN LATBbits.LATB7 /* PORT for RS */ #define TRIS_E TRISCbits.TRISC13 /* TRIS for E */ #define TRIS_RW TRISBbits.TRISB8 /* TRIS for RW */ #define TRIS_RS TRISBbits.TRISB7 /* TRIS for RS */ #ifdef EIGHT_BIT_INTERFACE #define DATA_PIN_3 LATDbits.LATD3 #define DATA_PIN_2 LATDbits.LATD2 #define DATA_PIN_1 LATDbits.LATD1 #define DATA_PIN_0 LATDbits.LATD0 #define READ_PIN_3 PORTDbits.RD3 #define READ_PIN_2 PORTDbits.RD2 #define READ_PIN_1 PORTDbits.RD1 #define READ_PIN_0 PORTDbits.RD0 #endif #ifdef EIGHT_BIT_INTERFACE #define TRIS_DATA_PIN_3 TRISDbits.TRISD3 #define TRIS_DATA_PIN_2 TRISDbits.TRISD2 #define TRIS_DATA_PIN_1 TRISDbits.TRISD1 #define TRIS_DATA_PIN_0 TRISDbits.TRISD0 #endif /* Display ON/OFF Control defines */ các phần sau thì giống file gốc Code:
#include <p30f4011.h> #include "xlcd.h" _FOSC(CSW_FSCM_OFF & FRC_PLL4); _FWDT(WDT_OFF); _FBORPOR(PBOR_ON & BORV_27 & PWRT_16 & MCLR_DIS); _FGS(CODE_PROT_OFF); void main() { OpenXLCD(FOUR_BIT & TWO_LINE & SEG1_50_SEG51_100 & COM1_COM16); //Khoi tao lcd PutsXLCD("Hello world"); //Hien thi mot xau tren dong thu nhat SetDDRamAddr(0x40); //Dua con tro ve dau dong thu hai PutsXLCD("30f4011-LCD"); //Hien thi mot xau tren dong thu hai while(1); return 0; } Code:
Make: The target "C:\Documents and Settings\NGUYEN THE TUNG\Desktop\C30\LCD\lcd.o" is out of date. Executing: "C:\Program Files\Microchip\MPLAB C30\bin\pic30-gcc.exe" -mcpu=30F4011 -x c -c "lcd.c" -o"lcd.o" -g -Wall pic30-coff-cc1.exe: warning: Resource version (3.01) does not match compiler! lcd.c:10: warning: return type of `main' is not `int' lcd.c: In function `main': lcd.c:12: warning: implicit declaration of function `PutsXLCD' lcd.c:18: warning: `return' with a value, in function returning void lcd.c:19:2: warning: no newline at end of file Resource version (3.01) does not match! Make: The target "C:\Documents and Settings\NGUYEN THE TUNG\Desktop\C30\LCD\delay.o" is up to date. Make: The target "C:\Documents and Settings\NGUYEN THE TUNG\Desktop\C30\LCD\OpenXLCD.o" is up to date. Make: The target "C:\Documents and Settings\NGUYEN THE TUNG\Desktop\C30\LCD\PutsXLCD.o" is up to date. Make: The target "C:\Documents and Settings\NGUYEN THE TUNG\Desktop\C30\LCD\ReadAddrXLCD.o" is up to date. Make: The target "C:\Documents and Settings\NGUYEN THE TUNG\Desktop\C30\LCD\ReadDataXLCD.o" is up to date. Make: The target "C:\Documents and Settings\NGUYEN THE TUNG\Desktop\C30\LCD\setCGRamAddr.o" is up to date. Make: The target "C:\Documents and Settings\NGUYEN THE TUNG\Desktop\C30\LCD\setDDRamAddr.o" is up to date. Make: The target "C:\Documents and Settings\NGUYEN THE TUNG\Desktop\C30\LCD\WriteCmdXLCD.o" is up to date. Make: The target "C:\Documents and Settings\NGUYEN THE TUNG\Desktop\C30\LCD\WriteDataXLCD.o" is up to date. Make: The target "C:\Documents and Settings\NGUYEN THE TUNG\Desktop\C30\LCD\BusyXLCD.o" is up to date. Make: The target "C:\Documents and Settings\NGUYEN THE TUNG\Desktop\C30\LCD\LCD 4 bit.cof" is out of date. Executing: "C:\Program Files\Microchip\MPLAB C30\bin\pic30-gcc.exe" -mcpu=30F4011 "lcd.o" "delay.o" "OpenXLCD.o" "PutsXLCD.o" "ReadAddrXLCD.o" "ReadDataXLCD.o" "setCGRamAddr.o" "setDDRamAddr.o" "WriteCmdXLCD.o" "WriteDataXLCD.o" "BusyXLCD.o" -o"LCD 4 bit.cof" -Wl,-L"C:\Program Files\Microchip\MPLAB C30\lib",--script="C:\Program Files\Microchip\MPLAB C30\support\gld\p30f4011.gld",-Map="LCD 4 bit.map",--report-mem Resource version (3.01) does not match! Executing: "C:\Program Files\Microchip\MPLAB C30\bin\pic30-bin2hex.exe" "C:\Documents and Settings\NGUYEN THE TUNG\Desktop\C30\LCD\LCD 4 bit.cof" Resource version (3.01) does not match! Loaded C:\Documents and Settings\NGUYEN THE TUNG\Desktop\C30\LCD\LCD 4 bit.cof. BUILD SUCCEEDED: Thu Nov 13 11:50:45 2008 thay đổi nội dung bởi: tungtuantu, 13-11-2008 lúc 12:04 PM. |
![]() |
![]() |
![]() |
#2 |
Đệ tử 3 túi
Tham gia ngày: Jul 2008
Bài gửi: 58
: |
Pic24
các bác ơi!
sao em không thấy ai bàn về chủ đề PIC24???? em muốn nghiên cứu về PIC24 nhưng không biết dòng PIC24 nào phổ biến???? tìm trên diễn đàn thì không thấy bàn về PIC24??? các bác giúp em với???? thanks! |
![]() |
![]() |
![]() |
|
|