Hello Jan, On 05/09/2012 09:11 PM, Jan Kromhout wrote: > I think that is a good idea to have the standard/elementary > words have in AMForth like setting a port to input/output, or > the analog output and the I2C connection like the wire > routine.
To set input/output direction, pin levels high/low, etc. the two most important files imho would be amforth/releases/4.8/core/devices/atmega328p/atmega328p.frt amforth/releases/4.8/lib/bitnames.frt Change 4.8 and atmega328p according to your release and controller. Once you load these files to your running arduino, you can do things like these: \ small led is connected to pin B.5, labeled "digital 13" PORTB 5 portpin: led led pin_output led high The small led on the duemilanove board (probably on the uno, too) should now light up. The constant PORTB is defined in atmega328p.frt. The words pin_output high low pin_input ... in file bitnames.frt There are words bm_set bm_clr bm_toggle ( mask addr -- ) which will operate on one or more bits at once. Activating PWM or I2C or whatever needs to set bits here and there. The datasheet is the best reference for anything, even though it may be hard to read. So turning i2c (called twi) on and off should look like this \ enable twi \ TWBR = $03, TWPS[10] = $03 \ ==> 28 kHz (f_cpu: 11059200) : +twi ( -- ) $00 TWCR c! $03 TWBR c! $03 TWSR c! ; \ turn off twi : -twi ( -- ) 0 TWCR c! ; please hunt through the directories https://amforth.svn.sourceforge.net/svnroot/amforth/releases/4.8/appl/ https://amforth.svn.sourceforge.net/svnroot/amforth/applications/ https://amforth.svn.sourceforge.net/svnroot/amforth/releases/4.8/examples/ if you can read German, I also suggest you have a look through the "Vierte Dimension" issues found at http://www.forth-ev.de/ > Download > Vierte Dimension > pdf Archive same as http://www.forth-ev.de/filemgmt/viewcat.php?cid=2 Cheers, Erich ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Amforth-devel mailing list for http://amforth.sf.net/ Amforth-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/amforth-devel