> Em 24/8/2010 10:39, Carl Denk escreveu:
>
>> I am in need of 2.5 serial ports on the 18F1320, (1) RS-232, (1) RS485,
>> and (1) Serial LCD, Tx only). The RS-232 would be the hardware USART,
>> and the others would be Software Uart's. I understand the part of
>> modifying the specific Library files, and rebuilding after revising the
>> PORT numbers. Here's the approach I'm thinking:
>> 1: Copy 2 sets of the library sw_uart files to the project directory.
>> 2: Rename one of the sets of files, say append "_2".
>> 3: On the first set of files change the ports, function, and file
>> references to match the first UART.
>> 4: On the 2nd set of files do the same.
>> 5: Rebuild both sets of library files.
>> 6: There will be 2 sets of function calls with different names
>>
>> A couple of questions:
>> 1: Is there a way to economize on code size? I'm thinking that could add
>> an arguement to the functions where need be to specify which software
>> ports we are pointing.
>>
> It is a good idea, not only to save code (perhaps not that much savings
> anyway), but to have a more homogeneous and flexible approach.
>
> I posted some code in the thread "[PIC] C18 function prototypes
> (pic18f8627)", related to SPI, but the idea is the same.
>
>
>
>> 2: I haven't looked in detail, but, I'm assuming not all of the
>> sw_uart's files are port dependent, and will have no changes. Since they
>> are small and storage in project directory isn't an issue, is there a
>> reason to rebuild them, or will they just come along for the ride?
>>
> By keeping the files in the project tree, you don't need to rebuild the
> library, but if you stop using some of them, you must remember to remove
> them from the source files list or else they will still be linked and
> wasting program memory.
> If you build a library, then the linker ignores the functions that are
> not called.
>
> You don't need to rebuild the compiler's library, you could create a
> smaller library with just your new functions and add this library to the
> project. If the functions in your library have the same name as some in
> the original library, then your library must be listed before the
> original one in the project.
>
>
> It is only worth the hassle of rebuilding the library if you plan to use
> these functions on several projects. If they are intended for one
> project only, then add the files directly to the project or create a
> smaller library.
>
> I at first keep the files added directly to the project. If I feel that
> the files may be useful for other projects, and after they are very
> stable, tested and bug-free, then I move them to a library.
>
>
>> Thanks for comments. :)
>>
> Best regards,
>
> Isaac
>
>
> __________________________________________________
> Fale com seus amigos de graça com o novo Yahoo! Messenger
>
http://br.messenger.yahoo.com/
>