© Horst Hübel Würzburg
2005 - 2011
Token Code
Index Glossary of general commands
Glossary of 'Avise 2.4' I/O commands: W. Schemmert, Cinetix mit Ergänzungen von H.H.
In the versions for the AT90S4433 some functions are missing due to lack of code memory. Enter WORDS to get a list of functions of your specific version. Differences between different hardware versions are outlined where necessary +W(x addr -- ) token code = A6 (not available for AT90S4433 with external EEPROM)
Adds the second stack entry "x" directly to the value of SRAM cell located
at "addr" (must be within SRAM addresses
<= 0xFF), i.e. specially intended for manipulation of 'Avise' global variables
-W( x addr -- ) token code = A9 (not available for AT90S4433 with external EEPROM)
subtracts the second stack entry "x" directly from the value of SRAM cell
located at "addr" (must be within SRAM addresses
<= 0xFF), i.e. specially intended for manipulation of 'Avise' global variables
AIN( bsel -- x ) token code = 8C(only for CPU models with built-in ADC)
Start one single measurement of the AT90LS4433, AT90S8535 or ATmega163 internal
ADC converter, multiplexer input "bsel" selected. Ab- oder Zuschalten von Pullup-Widerständen: Beispiel: 7 AIN . // Spannungsmessung an Port A7 Hinweis: Gebraucht man AIN ohne weitere Maßnahmen, kann man sehr einfach Spannungsabfälle an Widerständen (z.B. Fotowiderständen messen, die zwischen dem Portpin Ax (x = 0, ... 7) und Masse angeschlossen sind. In dieser Gebrauchsart ist AIN nicht geeignet, um externe Spannungen zu messen. Im Normalzustand sind innere Pullup-Widerstände des Mikrocontrollers zugeschaltet. (Größenordnung 50 kOhm). Will man externe Spannungen messen, muss man diese Pullup-Widerstände abschalten. Beispiel: 7F A WDDR // Pin7 von Port A auf Eingang schalten, alle anderen Pins von Port A auf Ausgang (hier belanglos) 0 A WPORT // bei PIN 7 wird Pullup-Widerstand abgeschaltet, von Pin 0 ,... 6 wird 0 ausgegeben
Mit 7 AIN . erhält man jetzt die extern angelegte Spannung
BCLR( addr b -- ) token code = 83
Clear bit (set to 0=L) at position "b" (0...15) of SRAM byte at address
"addr".
BSET( addr b -- ) token code = 82
Set bit (set to 1=H) at position "b" (0...15) of SRAM byte at address
"addr".
BTST( addr b -- TRUE|FALSE ) token code = 84
Test bit at position "b" (0...15) of SRAM byte at address "addr". TRUE is
reported, if bit is set (=1, high), FALSE else
COUNT( -- x ) token code = 91 (not available for AT90S4433) The negative pulses on the INT1 input (PortD,3 for AT90S8515 and AT90S8535) are permanently counted in a background process. COUNT reports the present value of this counter. Circular overflow behaviour. See also ENCODE
ENCODE( -- x ) token code = 92 (not available for AT90S4433) Similar function as COUNT, but a counter is incremented or decremented depending on the present level of a second input PortD,4 (AT90S8515) respectively PortD,6 (AT90S8535). Circular overflow behaviour. This function is useful together with 2-phase rotary encoders. When used with mechanical encoders, these must be debounced with appropriate external hardware!
FREQ ist entfallen. Ersatz: WAVE für f< 16 kHz oder selbstprogrammiertes Wort , auch für größere Frequenzen: : FREQ D5 PBLO 0 4B W 4A W 40 4F W 9 4E W; (Timer 1: Ausgabe über PORT D,5) : FREQ D4 PBLO 0 4B W 4A W 40 4F W 9 4E W; (Timer 1: Ausgabe über PORT D,4) Es erwartet auf dem Stack einen Teiler b (1 Byte), der die Frequenz bestimmt nach der Formel: f = 8 000 kHz / (2.b+1) b = 64H = 100 decimal liefert demnach recht genau 40 kHz. Es gibt auch ein analoges Wort für TIMER2. Eine Übersicht über die verwendeten Timer erhalten Sie hier:
IACK( -- TRUE|FALSE ) token code = E1 Sends the I2C ACKNOWLEDGE command on the I2C interface. Success is reported as a boolean flag on the stack. User has to decide how to handle FALSE answer.
IRECV( -- b ) token code = E2 (not available for AT90S4433)
Receives one byte through the I2C interface performing the "current read"
method without ACK. Note that this is a receive primitive. According to the
I2C protocol, further commands have to be executed previously to ensure correct
read address; and further commands may have to be hooked after to close the
interface correctly.
ISEND( b -- ) token code = E3 (not available for AT90S4433)
Sends one byte via the I2C interface without ACK. Note that this is a send
primitive. To perform a real write operation to the I2C interface, a sequence
of further commands is necessary. Refer to the I2C protocol of the specific
device to be connected.
ISPEED( TRUE|FALSE -- ) token code = DE (not available for AT90S4433)
Adjust the I2C bus clock speed: TRUE does set it to 400 kHz speed (or maximum
possible); FALSE does limit it to 100 kHz speed.
ISTART( -- ) token code = DF (not available for AT90S4433)
Sends the I2C START command on the I2C interface.
ISTOP( -- ) token code = E0 (not available for AT90S4433)
Sends the I2C STOP command on the I2C interface.
PBRD( b -- TRUE|FALSE ) token code = 88
"Pin Bit ReaD". Reads one byte from the specified microcontroller I/O port
(PINx register) tests the questionned bit and puts the result conditionned
as a boolean flag on the data stack.
PBHI( b -- ) token code = 86 "Port Bit HIgh". Sets one bit at the specified microcontroller I/O port (PORTx register, DDRx register) to INPUT with PullUp resistor ("SOFT HIGH"). Comment on port bit coding see PBRD.
PBLO( b -- ) token code = 87 "Port Bit LOw". Sets one bit at the specified microcontroller I/O port (PORTx register, DDRx register) to OUTPUT LOW. Comment on port bit coding see PBRD.
PWM8( bhi bmod-- ) token code = 95
Start AVR timer 1 or
2 in 8 bit PWM mode.
PWM10(xhi bmod -- ) token code = 96 (not available for AT90S4433)
Starts the AVR timer 1 in 10 bit PWM mode.
Zur Ansteuerung der Servos braucht man Pulsbreiten zwischen 0,5 ms und 1,5 ms. Dazu können frühere Erfahrungen genutzt werden, wenn statt des früheren PWMX das aktuelle PWM10 bei gleichem Aufruf verwendet wird. Verwenden Sie dafür nicht PWM8 ! Beispiel: 60 A3 PWM10 Verwendet wird Timer1A (Port D.5). Der Vorteiler wird durch 3 eingeschaltet, nämlich 64. Damit ergibt sich aus der Grundfrequenz f 0 = 8 MHz / 2.1024 = 3,90625 kHz die Frequenz f0 /64 = 61 Hz. Eine Periodendauer beträgt also 1 /61 s = 16,384 ms. Mit 60(16) = 96(10) wird die Dauer der H-Phase eingestellt. Diese beträgt 96/1024 von 16,384 ms = 1,536 ms. Das entspricht quasi dem Idealwert 1,5 ms für "Stillstand". 2C (16) = 44 (10) stellt eine H-Phase von 44/1024 von 16,384 ms = 0,704 ms ein. 9C(16) = 156(10) stellt eine H-Phase von 156/1024 von 16,384 ms = 2,496 ms ein. Die letzten beiden Werte könnten - abhängig vom verwendeten Servo - zu den beiden Endstellungen links bzw. rechts gehören. Auch der Timer2 stellt ein PWM zur Verfügung. Das kann leicht selbst programmiert werden, wenn man in die zuständigen Prozessor-Register bestimmte Werte einträgt.
R( addr -- x ) token code = 80
Reads one data word from the microcontroller SRAM memory space to the data
stack. According to the AVR memory model, this can be a controller register,
controller SRAM (address <=0xFF) or an I/O register. <0x60, then only TOSL is read from "addr" and TOSH is set = 0.
RPIN( addr -- b ) token code = 8B Reads one byte from the specified microcontroller I/O port (PINx register) and puts the result on the data stack. In contrast to PBIN, this is a multiple line reading byte operation. The addressed port is specially coded in byte "addr": it describes the port name and may have the hex values 0x0B,0x0C,0x0D. (0x0A is allowed for kernel modifications with AT90S4414, AT90S8515 or AT90S8535). The PINx register readout is returned on the stack without further filtering. Note that not all port lines are physically available and some of the available ones may have special functions, which do not represent user I/O.
W(x addr -- ) token code = 81
Write one data word from the data stack to the microcontroller SRAM memory
space (address
<= 0xFF). According to the AVR memory model, this can be a controller register,
controller SRAM or an I/O register.
WAVE( b -- ) token code = 93 (AT90S4433: performs always 50% duty cycle)
Start the AVR timer 1 as frequency generator
with a low cycle period defined by WAVELO. Before
starting WAVE, the low period MUST be set with WAVELO. When WAVE is already
busy, every part can be changed independently. The low period, however, must
not be greater or equal than the total period. Frequency range is about
15 Hz to 32 kHz. Frequency is about 62500
kHz/(b+1). 16 bit resolution of frequency control.
Port OC1A (CPU depdendent) is set as output by 'Avise' firmware.
Vgl. auch FREQ und HZ
WAVELO( b -- ) token code = 94 (not available for AT90S4433) Sets the duration of the low period of WAVE in units of about 16 microseconds.
WDDR
( b addr -- ) token code = 8A
Lesen von externen Signalen ohne Pullup-Widerstände: Eingang "spannungsempfindlich" ff c wddr // Schaltet alle PINS von Port C auf Ausgang, damit in PORT C geschrieben werden kann 0 c wport // Schreibt 0 in Port C, d.h. alle Pullup-Widerstände werden abgeschaltet. 0 c wddr // Schaltet alle PINS von PORT C auf Eingang, damit äußere Spannungen gelesen werden können Lesen von externen Signalen mit Pullup-Widerständen: Eingang "strom- oder widerstandsempfindlich" (sonst "spannungsempfindlich"): ( 0 c wddr // Schaltet alle Pins von Port C auf Eingang, damit über PORT C eingelesen werden kann; dennoch: ) 0 c wport // Schreibt 0 in Port C, d.h. löscht alle Bits; alle Pullup-Widerstände werden abgeschaltet, damit äußere Spannungssignale gelesen werden können, z.B. vom Ausgang des Infrarot-Entfernungsmessers. ff c wport // Schreibt ff in Port C, d.h. setzt alle Bits; alle Pullup-Widerstände werden eingeschaltet, damit Spannungsabfälle an äußeren Sensoren (mechanischer Schalter, Potentiometer, Transistorschalter, Fototransistor, LDR, ... ) gelesen werden können.
WPORT
( b addr -- ) token code = 89
XR
( addr -- b ) token code = EF (not available for
AT90S4433 without external EEPROM)
XW
( b addr -- ) token code = F0 (not available for
AT90S4433 without external EEPROM)
ZR
( addr -- b ) token code = ED
ZW
( b addr -- ) token code = EE
Abbreviations and notation used in this glossaryDont be confused by these bureaucratic things. Look at the "programming crashcourse". Start programming by copy and modify. For each word entry there is a boldface headline, in which the most essential features are concentrated. E.g. an imaginary one:
TEST( x -- addr ; <namestring> ) token code = 4B
On top, there is the word name in big letters ( consumed stack entries -- produced stack entries ) or
The upper or youngest stack entry is positionned most right. Deeper stack
entries, which are not influenced by this word, are not listed in the stack
comment. If you have to do complicated operations, you are advised to solve
them writing your own stack comments. Following abbreviations are used in the stack commands:
The mnemonics in the stack comment give some hints relating the data type
which is effectively handled (though in a technical sense ''Avise'' can only
handle bytes on the stack). Longer data are represented by two or more stack
entries.
'Avise' does not know formal declarations of data types. Correct
interpretation - and in case re-interpretation - lies in the programmer's
responsibility.
Token Code
Index
|