vn00426941
21-03-2015, 07:56 PM
Mình đang tìm hiểu phần UART của con dspic 6014A nhưng mà viết code xong build nó toàn báo lỗi. Mình viết thử 1 dòng để cấu hình UART1 thôi mà build nó cũng báo lỗi. Ace nào chỉ giúp mình code nó bị sai chỗ nào.
Code:
#include "../support/h/p30f6014A.h"
#include "../support/gld/../h/libpic30.h"
#include "../support/h/peripheral_30F_24H_33F/uart.h"
#ifndef __DELAY_H
#define FOSC 40000000LL // clock-frequecy in Hz with suffix LL (64-bit-long),
#define FCY (FOSC/4) // MCU is running at FCY MIPS
#define delay_us(x) __delay32(((x*FCY)/1000000L)) // delays x us
#define delay_ms(x) __delay32(((x*FCY)/1000L)) // delays x ms
#define __DELAY_H 1
#endif
_FOSC(CSW_FSCM_OFF&HS3_PLL4 );
_FWDT (WDT_OFF);
_FBORPOR(MCLR_EN & PWRT_OFF);
_FGS(CODE_PROT_OFF);
main()
{
OpenUART1( UART_EN & UART_NO_PAR_8BIT & UART_1STOPBIT,
UART_INT_TX & UART_TX_ENABLE & UART_INT_RX_CHAR,
64);
};
Phần MPLAB báo lỗi:
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory 'D:/Lap trinh vi xu ly/thuc tap tot nghiep/test mach.X'
make -f nbproject/Makefile-default.mk dist/default/production/test_mach.X.production.hex
make[2]: Entering directory 'D:/Lap trinh vi xu ly/thuc tap tot nghiep/test mach.X'
"C:\Program Files (x86)\Microchip\MPLAB C30\bin\pic30-gcc.exe" -g -omf=elf -x c -c -mcpu=30F6014A -MMD -MF build/default/production/filechinh.o.d -o build/default/production/filechinh.o filechinh.c
"C:\Program Files (x86)\Microchip\MPLAB C30\bin\pic30-gcc.exe" -omf=elf -mcpu=30F6014A -o dist/default/production/test_mach.X.production.elf build/default/production/filechinh.o -Wl,--defsym=__MPLAB_BUILD=1,-Map="dist/default/production/test mach.X.production.map",-Tp30f6014A.gld
build/default/production/filechinh.o(.text+0x8): In function `.LM2':
: undefined reference to `_OpenUART1'
make[2]: *** [dist/default/production/test_mach.X.production.hex] Error 255
nbproject/Makefile-default.mk:119: recipe for target 'dist/default/production/test_mach.X.production.hex' failed
make[2]: Leaving directory 'D:/Lap trinh vi xu ly/thuc tap tot nghiep/test mach.X'
nbproject/Makefile-default.mk:75: recipe for target '.build-conf' failed
make[1]: Leaving directory 'D:/Lap trinh vi xu ly/thuc tap tot nghiep/test mach.X'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 753ms)
Ace nào biết cách dùng thư viện C30 viết phần UART xem hộ mình bị sai chỗ nào. Mình tìm code mẫu về UART dùng thư viện C30 mà k thấy có trên mạng. Cám ơn mọi người.
Code:
#include "../support/h/p30f6014A.h"
#include "../support/gld/../h/libpic30.h"
#include "../support/h/peripheral_30F_24H_33F/uart.h"
#ifndef __DELAY_H
#define FOSC 40000000LL // clock-frequecy in Hz with suffix LL (64-bit-long),
#define FCY (FOSC/4) // MCU is running at FCY MIPS
#define delay_us(x) __delay32(((x*FCY)/1000000L)) // delays x us
#define delay_ms(x) __delay32(((x*FCY)/1000L)) // delays x ms
#define __DELAY_H 1
#endif
_FOSC(CSW_FSCM_OFF&HS3_PLL4 );
_FWDT (WDT_OFF);
_FBORPOR(MCLR_EN & PWRT_OFF);
_FGS(CODE_PROT_OFF);
main()
{
OpenUART1( UART_EN & UART_NO_PAR_8BIT & UART_1STOPBIT,
UART_INT_TX & UART_TX_ENABLE & UART_INT_RX_CHAR,
64);
};
Phần MPLAB báo lỗi:
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory 'D:/Lap trinh vi xu ly/thuc tap tot nghiep/test mach.X'
make -f nbproject/Makefile-default.mk dist/default/production/test_mach.X.production.hex
make[2]: Entering directory 'D:/Lap trinh vi xu ly/thuc tap tot nghiep/test mach.X'
"C:\Program Files (x86)\Microchip\MPLAB C30\bin\pic30-gcc.exe" -g -omf=elf -x c -c -mcpu=30F6014A -MMD -MF build/default/production/filechinh.o.d -o build/default/production/filechinh.o filechinh.c
"C:\Program Files (x86)\Microchip\MPLAB C30\bin\pic30-gcc.exe" -omf=elf -mcpu=30F6014A -o dist/default/production/test_mach.X.production.elf build/default/production/filechinh.o -Wl,--defsym=__MPLAB_BUILD=1,-Map="dist/default/production/test mach.X.production.map",-Tp30f6014A.gld
build/default/production/filechinh.o(.text+0x8): In function `.LM2':
: undefined reference to `_OpenUART1'
make[2]: *** [dist/default/production/test_mach.X.production.hex] Error 255
nbproject/Makefile-default.mk:119: recipe for target 'dist/default/production/test_mach.X.production.hex' failed
make[2]: Leaving directory 'D:/Lap trinh vi xu ly/thuc tap tot nghiep/test mach.X'
nbproject/Makefile-default.mk:75: recipe for target '.build-conf' failed
make[1]: Leaving directory 'D:/Lap trinh vi xu ly/thuc tap tot nghiep/test mach.X'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 753ms)
Ace nào biết cách dùng thư viện C30 viết phần UART xem hộ mình bị sai chỗ nào. Mình tìm code mẫu về UART dùng thư viện C30 mà k thấy có trên mạng. Cám ơn mọi người.