Avr is the root class (the Controller). Die Property „Device“ must be declared before all others.
Property (write only) | ||
---|---|---|
Name | Description | Value |
Avr.Device=Controllername | selects controller class 1) | Name |
Avr.Clock=Constant | Clock rate in Hz 2) | > 0 |
Avr.Stack=Constant | Stack size in Byte. | > 1 |
Avr.Isr.<InterruptAdr>=Isr-Label | Define the Interrupt service routine.3) | Address |
Avr.CodeStartAddr=Address | Start address of the code, e.g. for Bootloader „avr.CodeStartAddr = LARGEBOOTSTART“. This will write the machine code to the specifies address in memory. | Address (Word oriented) |
Property (read only) | ||
Name | Description | Type |
Result = Avr.StackPointer | Current stack pointer position | word |
Property (read/write) | ||
Name | Description | Type |
Avr.<Portname> | Direct access to all ports. | byte |
Avr.<Portname>.<Bit> | Direct access to the bits of the specified port. | byte |
Method | ||
Name | Description | |
Avr.Interrupts.enable | Enable global interrupts ON | |
Avr.Interrupts.disable | Disable global interrupts OFF | |
Avr.Idle | will call Idle-Event if available. |
avr.device = atmega32 // Atmega32 avr.clock = 8000000 // 8 Mhz clock rate avr.stack = 32 // 32 Byte program stack // Program code
The required stack size depends on the number of parameters and local variables and cascading level of method calls. Cascaded calls add their number of required byte. A method requires at least 2 byte (Return address). Parametera and declared variables come on top.
Besides using ojects and functions, you may also access the ports directly (same as in C/Assembler). All controller specific Bit names or properties of the specific port are defined. Luna-IDE will highlight correctly written and existent names. Ports and names of the avr.device-Properties will be updated when loading or saving the source code.
Generally speaking:
value = avr.SREG 'default data type is byte avr.TCNT1.Word = value 'define word access (write) value = avr.TCNT1.Word '(read)
See also: ermitteln_von_controllerspezifischen_werten_und_konstanten
avr.device = atmega32 // Atmega32 avr.clock = 8000000 // 8 Mhz clock rate avr.stack = 32 // 32 Byte program stack dim a as word dim b as byte avr.TIMSK = 1<<TOIE1 or 1<<OCIE1A ' Activate Timer 1 and Compare1A a.LowByte = avr.TCNT1L ' Read Low Byte of timer counter a.HighByte = avr.TCNT1H ' Read High Byte of timer counter avr.TCNT1H = a.HighByte ' Write High-Byte of timer counter (when writing, always High byte first!) avr.TCNT1L = a.LowByte ' Write Low-Byte of timer counter avr.DDRA.PINA0 = 1 b = avr.PORTA.PINA0 avr.Isr.ICP1Addr = myIsr do loop isr myIsr [..] endisr