From: Ken J. <Ken...@ie...> - 2006-05-04 01:16:20
|
By making SerialSetup() a function, you are requiring it to actually do the division at runtime, not compile time. Is that necessary? If you are only using one baude rate, it would be much better to not pass it but plug it in directly so the division can be done by the compiler at compile time. If you have a few different baud rates, it would be better to calculate the values for SPBRG at compile time, put them in an array, and pick one at run time. BTW, I'm not sure what SDCC does, but you should put an 'L' at the end of 20000000 (i.e. 20000000L), otherwise some compilers will assume it's an int and truncate it. -Ken Jackson Luciano de Barros writes: > Hi, > > I'm converting my applications to SDCC PIC14, in one this use a macro to calculate USART baudrate, when compile the code are returned errors: > > error: missing definition for symbol "__mullong", required by "main.o" > error: missing definition for symbol "__divslong", required by "main.o" > > If change code lines with macro to main() function this error is not occured. > > Sample code: > > //----------------------------------------------------------------------------- > #include "pic16f877defs.h" > > CONFIG( _CP_ALL & _DEBUG_OFF & _WRT_ENABLE_OFF & _CPD_ON & _LVP_ON & _BODEN_OFF & _PWRTE_ON & _WDT_OFF & _HS_OSC); > > #define XTAL 20000000 > > //----------------------------------------------------------------------------- > #define LBAUDRATE(b) ((XTAL/(b*64))-1) // Calc BaudRate in Low Speed > #define HBAUDRATE(b) ((XTAL/(b*16))-1) // Calc BaudRate in High Speed > > //----------------------------------------------------------------------------- > void SerialSetup(long baud) > { > if(baud<=9600) > SPBRG = (unsigned char) LBAUDRATE(baud); > else > SPBRG = (unsigned char) HBAUDRATE(baud); > > } > > //----------------------------------------------------------------------------- > void main(void) > { > > SerialSetup(9600); > while(1){ > } > } > > //----------------------------------------------------------------------------- > > Regards, > > Luciano |