Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Thread

Stack

Stack

2004-12-23 by Paul Maddox

Dear all,

  Daft question, I'm trying to setup a couple of IRQs (in assembly) and I'm
getting some odd results, here's the first part of my setup ;-

  LDI  Temp, Low(Ramend)
  OUT  SPL, Temp    ; setup stack pointer

  LDI  Temp, High(Ramend)
  OUT  SPH, Temp

  ; **** setup IRQs

  LDI  Temp, 0b00001010
  OUT  MCUCR,Temp    ; Setup MCUCR for falling edge interupts.

  LDI  Temp, 0b11000000   ; enable ext. INT1 and INT0
  OUT  GICR,Temp    ; by setting General Interupt Control Register

I assume the stack and IRQ setup is ok?
or is it shot to peices?

Paul

Re: [AVR-Chat] Stack

2004-12-23 by Leon Heller

----- Original Message ----- 
Show quoted textHide quoted text
From: Paul Maddox
To: AVR-Chat@yahoogroups.com
Sent: Thursday, December 23, 2004 1:40 PM
Subject: [AVR-Chat] Stack


Dear all,

  Daft question, I'm trying to setup a couple of IRQs (in assembly) and I'm
getting some odd results, here's the first part of my setup ;-

  LDI  Temp, Low(Ramend)
  OUT  SPL, Temp    ; setup stack pointer

  LDI  Temp, High(Ramend)
  OUT  SPH, Temp

  ; **** setup IRQs

  LDI  Temp, 0b00001010
  OUT  MCUCR,Temp    ; Setup MCUCR for falling edge interupts.

  LDI  Temp, 0b11000000   ; enable ext. INT1 and INT0
  OUT  GICR,Temp    ; by setting General Interupt Control Register

I assume the stack and IRQ setup is ok?
or is it shot to peices?

What is GICR???

You need to set the top two bits in GIMSK, then execute SEI. Make sure you 
have the vectors initialised correctly.

Leon 



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.298 / Virus Database: 265.6.4 - Release Date: 22/12/2004

Re: [AVR-Chat] Stack

2004-12-23 by Paul Maddox

Dave,

> What's the chip??

sorry, I should've said.

MEga16

> What's your vector table look like?

fairly straight forward ;-
.ORG RESET
  RJMP INIT

.ORG INT0addr
  RJMP READPORTS

.ORG INT1addr
  RJMP SYNC

> I've seen some systems that only partially fill the vector table, but I
> really get squeamish at that.
> I prefer a full table, with at least RETI's on the unused ints, and
ideally
> a little code to turn them off in case they get accidentally turned on..

Hmmm, worth a go.

> Put that in your template for a given processor, and then just populate
the
> ones you want.  If you get pushed for space, then sacrifice the turnoffs
> for RETI's again.

Thanks, I'll take a look

Paul

Re: [AVR-Chat] Stack

2004-12-23 by Paul Maddox

Leon,

> What is GICR???

'General Interupt Control register'

> You need to set the top two bits in GIMSK, then execute SEI. Make sure you
> have the vectors initialised correctly.

I've got the SEI, and I think the IRQ vectors are ok, the GICR register is
the new version of GIMSK, dunno why they've changed it.

Paul

Re: [AVR-Chat] Stack

2004-12-23 by Leon Heller

----- Original Message ----- 
Show quoted textHide quoted text
From: Paul Maddox
To: AVR-Chat@yahoogroups.com
Sent: Thursday, December 23, 2004 2:11 PM
Subject: Re: [AVR-Chat] Stack


Leon,

> What is GICR???

'General Interupt Control register'

> You need to set the top two bits in GIMSK, then execute SEI. Make sure you
> have the vectors initialised correctly.

I've got the SEI, and I think the IRQ vectors are ok, the GICR register is
the new version of GIMSK, dunno why they've changed it.

Are you using the simulator? I use that to sort out out problems like those 
you are having.

Leon



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.298 / Virus Database: 265.6.4 - Release Date: 22/12/2004

Re: [AVR-Chat] Stack

2004-12-23 by Paul Maddox

Leon,

> Are you using the simulator? I use that to sort out out problems like
those
> you are having.

It all works fine in the simulator, but then it always did, and I've found a
couple of bugs since :-)
I've had an idea it might be to do with the lack of pullups on the data in
ports, so I've enabled those and I'll try again tonight.

Paul

Re: [AVR-Chat] Stack

2004-12-23 by Paul Maddox

Dave,

> If you have them set for low level, that might be quite significant :)

The IRQs are set for falling edge.
Its a simple 'network' with 5 of MEGA16s on, one controlling the other 4,
all the PORTA pins of all 5 are tied together, I figured I wouldn't need
pullups as there would always be something comming from the controller. same
for the IRQ lines.

Of the 7 parameters, 4 work perfectly, 3 don't seem to do the right thing, I
just get garbage instead of the correct value.

odd.

Paul

Re: [AVR-Chat] Stack

2004-12-23 by Dave VanHorn

At 08:40 AM 12/23/2004, Paul Maddox wrote:


>Dear all,
>
>   Daft question, I'm trying to setup a couple of IRQs (in assembly) and I'm
>getting some odd results, here's the first part of my setup ;-
>
>   LDI  Temp, Low(Ramend)
>   OUT  SPL, Temp    ; setup stack pointer
>
>   LDI  Temp, High(Ramend)
>   OUT  SPH, Temp
>
>   ; **** setup IRQs
>
>   LDI  Temp, 0b00001010
>   OUT  MCUCR,Temp    ; Setup MCUCR for falling edge interupts.
>
>   LDI  Temp, 0b11000000   ; enable ext. INT1 and INT0
>   OUT  GICR,Temp    ; by setting General Interupt Control Register
>
>I assume the stack and IRQ setup is ok?
>or is it shot to peices?

What's the chip??

What's your vector table look like?

I've seen some systems that only partially fill the vector table, but I 
really get squeamish at that.
I prefer a full table, with at least RETI's on the unused ints, and ideally 
a little code to turn them off in case they get accidentally turned on.. 
Put that in your template for a given processor, and then just populate the 
ones you want.  If you get pushed for space, then sacrifice the turnoffs 
for RETI's again.

Re: [AVR-Chat] Stack

2004-12-23 by Dave VanHorn

At 09:32 AM 12/23/2004, Paul Maddox wrote:


>Leon,
>
> > Are you using the simulator? I use that to sort out out problems like
>those
> > you are having.
>
>It all works fine in the simulator, but then it always did, and I've found a
>couple of bugs since :-)
>I've had an idea it might be to do with the lack of pullups on the data in
>ports, so I've enabled those and I'll try again tonight.

If you have them set for low level, that might be quite significant :)

Re: [AVR-Chat] Stack

2004-12-24 by Paul Maddox

All,

So, I found the problem last night, the clue was in this sentance.

> Of the 7 parameters, 4 work perfectly, 3 don't seem to do the right thing,
I
> just get garbage instead of the correct value.

I should've said, the first 3 don't work and the last 4 all do.
BIT2 of my 3 bit control was always high, and guess what, that pin on the
controller was set to input with a pullup, so, I'm an idiot :-)

Thanks for your suggestions, its helped 'tidy' the code a little :-)
Paul

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.