Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

AVR Assembler and timed Interrupts on OSHONSOFT

Status
Not open for further replies.

gentlegiant

New Member
Hi there fellow travelers,

I am experiencing a small issue with the OSHONSOFT AVR simulator ide, in that it doesnt seem to trigger any timer interrupts when running a simple timer interrupt program in assembler code.
Yet the same program seems to work well when stepping through with AVR Studio simulator.
Am i missing something????

HELP.
 
Hi there fellow travelers,

I am experiencing a small issue with the OSHONSOFT AVR simulator ide, in that it doesnt seem to trigger any timer interrupts when running a simple timer interrupt program in assembler code.
Yet the same program seems to work well when stepping through with AVR Studio simulator.
Am i missing something????

HELP.

hi,
If you have long Timer values, running in the Sim, takes a long time..
 
Thank you, for your fast response,
However, it seems no matter how long i wait and how short i make the time constant, it still does not cause any interrupts....:confused:
 
The Oshonsoft AVR sim is not as fully implemented as the PIC ones. Goto menu Help->Help topics and scroll to the end to see the list of simulated peripherals. From memory I don't think timers are implemented.
 
Thank you,
I seem to have come to that conclusion, from reading on other bloggs etc.. I will have to implement some way "around" this.. A pity , this simulator seems very impressive in viewing your pre-download programme...
 
Timers aren't implemented? That's silly! That's one of the most basic and massively important peripherals a micro controller has! Outside of the basic instructions and I/O operation timers should be the next on the list of things a simulator should support.
 
Last edited:
Thank you,
I seem to have come to that conclusion, from reading on other bloggs etc.. I will have to implement some way "around" this.. A pity , this simulator seems very impressive in viewing your pre-download programme...

hi,
Post your full code and I will try to run it in my OshIDE.

Interrupts are implemented in ALL the other MCU's I use with Oshonsoft, I will get the trial version of the AVR

E.

EXTRACT from AVR OSH Manual.
● Using interrupts

Interrupt routines should be placed as all other subroutines after the END statement. A separate routine should be implemented for every interrupt source used. The list of available interrupt sources for the selected AVR device with their official names can be viewed by selecting Show System Interrupt Names command from the Options menu of the basic compiler window. Interrupt routine should begin with ON INTERRUPT keyword followed by the official name of its interrupt source and it should end with RESUME statement. ENABLE and DISABLE statements followed by an interrupt source name can be used in the program to control the status of its enable flag. If used with no arguments they will control the status of the global interrupt enable flag (I-flag) in the SREG register. RESUME statement will automatically set the I-flag and enable new interrupts. One example:
Dim x As Byte
x = 255
DDRB = 0xff
PORTB = x
DDRD.2 = 0 'configure INT0 pin as an input pin
MCUCR.ISC00 = 1
MCUCR.ISC01 = 1 'INT0 rising edge generates an interrupt
Enable INT0
Enable
End

On Interrupt INT0
x = x - 1
PORTB = x
Resume
 
Last edited:
hi,
Downloaded and installed the Oshonsoft AVR trial.

Used the Interrupt example in the documentation [extract] it works OK with interrupts on INT0
 
Last edited:
Just to reiterate my post. I said I thought timers were not implemented NOT interrupts.

Here is the list of supported peripherals from the AVR Sim Help menu (v1.51):
- Digital I/O
- Data EEPROM Memory
- Interrupts
- External Interrupts INT0, INT1
- A/D Converter Module
- Analog Comparator Module
- USART Module

Note: Timers not mentioned so assume not implemented (YET!)

The creator of these sims has done a really wonderful job so far in producing really useful tools. Its absolute magic to be able to run your code against not only the controller but a lot of peripherals as well and debug most of the code before having to burn a chip.
But its also no wonder given the number of different controllers etc that keeping up with it all is a slow process. PIC is supported better than AVR but one day that may change!
 
Hi Gentelmen,

Here is the "simple" code i am trying to use in another programme.....




.NOLIST
.INCLUDE "m164Pdef.inc" ;
.LIST


.DEF rmp=R16
.DEF rBIN1H= R17
.DEF rBIN1L=R18
.DEF rBIN2H= R19
.DEF rBIN2L= R20


; STart of TEst Program

.CSEG
.org $0000
RJMP MAIN
.org $0024
RJMP TIM0_COMPA
MAIN:
LDI rmp,HIGH(RAMEND); Set the Stack
OUT SPH,rmp
LDI rmp,LOW(RAMEND)
OUT SPL, rmp

SBI DDRB,0 ;SET PORTB 0 FOR OUTPUT
LDI rmp,0b0000_0001 ;SET PRESCALER TO /1024
OUT TCCR0B,rmp ;TIMER/COUNTER CONTROL REGISTER "B"
LDI rmp,0b0000_0010 ;ENABLE TIMER-OVERFLOW INTERUPT
sts TIMSK0,rmp
LDI rmp,175 ;PRELOAD THE TIMER
OUT TCNT0,rmp
SEI ;ENABLE INTERUPTS GLOB

no_end: ;unlimited loop when done
RJMP no_end

TIM0_COMPA:
SBI PINB,0 ;FLIP THE 0 BIT
LDI rmp,160 ;RELOAD THE TIMER
OUT TCNT0,rmp
RETI


Now, before anyone jmps to any conclussions about the different time constant i am using. The only reason they arew different is so that i can KNOw that the interupt has occurred.. Aslo the original has a time constant of 1024 and here i am using no time constant. I* have stepped thru this code on AVR Studio 5 and it does work, but i cant gewt it to run in the simulator...

Any thoughts will be gratefully accepted and tried....

Thank you..
 
hi,
That simple code will not assemble, it terminates Oshonsoft when F9 [ assemble and load] is pressed, tried it 3 times.
 
Last edited:
I did assemble and load the code into AVR sim. Had to change the format of the binaries 0b0000_0001 and 0b0000_0010.
Nothing happens, no interrupts, no timer simulation -- because timers are not implemented.
 
Hi Robertkendrick,
Thats exactly what i experienced. so i a m not sure how to work around this.

Also, i dont quite understand the previous comment about the code "not assembling".

For me all i need to do is load the hex file from the AVR studio 5 program.....

Everything else works well, except the timers required for interupt routine.

Thank you for your "input"
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top