From: Marcel D. <mde...@my...> - 2007-03-17 20:54:52
|
Hi Windows users, here is how to assemble amForth 1.3 - 1.5 with Atmel's AVRStudio under Windows! Since I own a evaluation board with an atmega32, all the following hints refer to this controller and its related source files. They should be usable to the other controllers too, by replacing 'mega32' files with 'megaxx' where applicable. As for the moment I have not tested any of them. To build amForth create a new project in AVRStudio, perform the following steps: Select menu item: Project - New Project In the upcoming wizard, select: - Project type: Atmel AVR Assembler - Project name: amForth15 (or whatever you like) - Deselect option: Create initial file - Choose Location: Browse to the path of the amForth source files - Click: NEXT - Select Debug platform: AVR Simulator - Select Device: ATMega32 (or else the target controller you use) - Click: FINISH. AVRStudio creates the new project. In the left pane, right click on the "Sourcefiles" folder, select "Add Files" and select "p16.asm" (or else the main source file for your controller). AVRStudio inserts this file into the Sourcefiles list. Open it with a double click and change the settings for CPU clock and baudrate, if necessary (I use 8 MHz and 19200 bps foe example). Assemble by clicking on the "Assemble" button on the toolbar, or by hitting F7. Assembling the original source files with AVRASM2 in Atmel AvrStudio 4.12 yields the following errors: (numbered 1. to 5.). (You can open the respective source files by double-clicking the error lines. AVRStudio opens the corresponding source file in its editor.) 1. Invalid redifinition of 'RWWSRE' in atmega32.asm (line 16) 2. Invalid redifinition of 'UDR0' in atmega32.asm (line 22) These values are defined in m32def.inc in the first place (file comes with AVRStudio); Resolved by commenting out line 16 in atmega32.asm, by commenting out line 22 in atmega32.asm and by replacing UDR0 with UDR in atmega32.asm and usart.asm source files. (m32def.inc is a system file and must not be altered). Note: A fix should replace UDR0 in atmega32.asm with a new definition (e.g. UDR_0) or replace UDR0 with UDR in amForth sources. References to UDR0 are in: atmega8.asm atmega16.asm atmega32.asm atmega168.frt usart.asm I replaced UDR0 by UDR (24feb07, ok vor amforth 1.3 - 1.5)! 3. Undefined label TWSIaddr in atmega32.asm (line 68) Resolved by changing TWSIaddr into TWIaddr in line 68 4. Overlapping of object code in cseg in usart.asm (line 10) 5. Overlapping of object code in cseg in usart.asm (line 12) Atmels assembler does not accept multiple code sequences for the same address range (imho doing this is bad practice anyway). Resolved by commenting out several lines in usart.asm (lines 6..14) like this: /* .set pc_ = pc .org URXCaddr rjmp usart0_rx_isr .org UDREaddr rjmp usart0_udre_isr .org pc_ */ and by modifying interrupt vectors in atmega32.asm: .org URXCaddr ; USART Receive Complete Interrupt Vector Address rjmp usart0_rx_isr .org UDREaddr ; USART Data Register Empty Interrupt Vector Address rjmp usart0_udre_isr I modestly think the interrrupt vectors belong in atmega32.asm anyway (rather than in usart.asm). The resulting code now assembles with no error and runs on my evaluation board. Important note: in AvrStudio you must explicitly save any changed files before a new build! Corrections above yield the following values (e.a.): EQU URXCaddr 0000001a EQU UDREaddr 0000001c EQU RWWSRE 00000004 EQU UDR 0000000c EQU UDR0 00000000 ; These values seem to be correct. Any feedback welcome! md 24feb07, 17mar07 -- derri |