hardware interrupt, STK200

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi
We are a group of students at Uppsala University, Sweden. We are trying to
develop a balance system for a humanoid robot. To do this we use two AVR8515
and SPI. The problem is that it doesn´t seem to work. We wonder if there are
any limitations when using STK200. The hardware doesn´t wont to create any
interrupts.

Per Hammer

admin's test signature
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

The answer to your question is: no. The STK200 doesn't limit the use of interrupts, but your interrupt question remains to be resolved...

It'd be best if you could provide some sample code of how you've set up the interrupts, and a description of what you intend to do and how it goes wrong. In the meantime, I'll give some general info. The AT90S8515 datasheet should provide the rest :)

To set up your interrupts, you must first enable them. For external interrupts, this is done in the GIMSK register. If you're using external interrupts, you can set the sense control for these interrupts in the MCUCR register.

The SPI interrupt is enabled in the SPCR register. I noticed there's some example code on how to set up SPI master and slave further down in this forum (the posting is called 'SPI').

When you've successfully enabled your interrupts, you must enable the global interrupt with the SEI instruction before any interrupts are executed.

Are you using the STK200 boards in your robot directly? If so, how are they connected? If you're not, how are the '8515s connected? If your input pins cannot be driven low, external interrupts won't function. The STK200 provides the necessary pull-up resistors, but if you've released your application AVRs from the development board, there might be some problems with the pin connections.

Best regards,

Morten, AVR tech. support

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

...on closer inspection, that might have been yourself involved in the SPI discussion? Then it was unnecessary to point that out for you.

Looking forward to hearing more about your connections and setup code!

:)Morten

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello Morten!

We are using STK200 when we are testing the system, we will design our circuit board when it works. We will connect several AVR 8515 and 8535 to a CAN-bus, to communicate with a main computor. Right now we are using a CAN-dip as a master and a STK200 as a slave, but when we try to shift in a byte into the slave and then monitor it (by using the UART) nothing comes out of the slave. The interrupt function in the slave is not called upon. Below this you will find master and slave-code, made in CodeVision.

Regards, Lars

Project : Master

Chip type : AT90S8515
Clock frequency : 4,000000 MHz
Memory model : Small
Internal SRAM size : 512
External SRAM size : 0
Data Stack size : 128
*********************************************/

#include

// SPI interrupt service routine
unsigned char data=0xAA;
interrupt [SPI_STC] void spi_isr(void)
{

SPDR=data;
// Place your code here
SPCR=0xD2;
}

// Declare your global variables here

void main(void)
{
// Declare your local variables here

// Input/Output Ports initialization
// Port A
DDRA=0x00;
PORTA=0x00;

// Port B
DDRB=0xB0;
PORTB=0x00;

// Port C
DDRC=0x00;
PORTC=0x00;

// Port D
DDRD=0x00;
PORTD=0x00;

// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: Timer 0 Stopped
// Mode: Output Compare
// OC0 output: Disconnected
TCCR0=0x00;
TCNT0=0x00;

// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: Timer 1 Stopped
// Mode: Output Compare
// OC1A output: Discon.
// OC1B output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
TCCR1A=0x00;
TCCR1B=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;

// External Interrupt(s) initialization
// INT0: Off
// INT1: Off
GIMSK=0x00;
MCUCR=0x00;

// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x00;

// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0x80;

// SPI initialization
// SPI Type: Master
// SPI Clock Rate: 62,500 kHz kHz
// SPI Clock Phase: Cycle Half
// SPI Clock Polarity: Low
// SPI Data Order: MSB First
SPCR=0xD2;

// Clear the SPI interrupt flag
#asm
in r30,spsr
in r30,spdr
#endasm

// Global enable interrupts
#asm("sei")
SPDR=data;
while (1)
{
// Place your code here

};
}
-------------------------------------------------------------------------------------------------------

Project : Slave

Chip type : AT90S8515
Clock frequency : 4,000000 MHz
Memory model : Small
Internal SRAM size : 512
External SRAM size : 0
Data Stack size : 128
*********************************************/

#include

// Standard Input/Output functions
#include

// SPI interrupt service routine
interrupt [SPI_STC] void spi_isr(void)
{
unsigned char data;
data=~SPDR;
// Place your code here
printf("Data %u",data);

}

// Declare your global variables here

void main(void)
{
// Declare your local variables here

// Input/Output Ports initialization
// Port A
DDRA=0x00;
PORTA=0x00;

// Port B
DDRB=0x40;
PORTB=0x00;

// Port C
DDRC=0x00;
PORTC=0x00;

// Port D
DDRD=0x00;
PORTD=0x00;

// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: Timer 0 Stopped
// Mode: Output Compare
// OC0 output: Disconnected
TCCR0=0x00;
TCNT0=0x00;

// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: Timer 1 Stopped
// Mode: Output Compare
// OC1A output: Discon.
// OC1B output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
TCCR1A=0x00;
TCCR1B=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;

// External Interrupt(s) initialization
// INT0: Off
// INT1: Off
GIMSK=0x00;
MCUCR=0x00;

// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x00;

// UART initialization
// Communication Parameters: 8 Data, 1 Stop, No Parity
// UART Receiver: Off
// UART Transmitter: On
// UART Baud rate: 9600
UCR=0x08;
UBRR=0x19;

// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0x80;

// SPI initialization
// SPI Type: Slave
// SPI Clock Rate: 62,500 kHz kHz
// SPI Clock Phase: Cycle Half
// SPI Clock Polarity: Low
// SPI Data Order: MSB First
SPCR=0xC2;

// Clear the SPI interrupt flag
#asm
in r30,spsr
in r30,spdr
#endasm

// Global enable interrupts
#asm("sei")

while (1)
{
// Place your code here

};
}

admin's test signature