导航: 老古网老古论坛XMOS公共讨论区XMOS开源项目区单片机程序设计嵌入式系统广告区域
→AVR单片机:急!请高人指点,我用GCC-AVR编程可是中断[xyzwp2000]

 *第3156篇: AVR单片机:急!请高人指点,我用GCC-AVR编程可是中断总也不开!

  
楼 主:xyzwp2000 2002年5月9日11:02
 AVR单片机:急!请高人指点,我用GCC-AVR编程可是中断总也不开!
/*
    Title:    AVR-GCC test program #2 for the STK200 eva board
    Author:   Volker Oth
    Date:     4/1999
    Purpose:  Flashes the LEDs on Port B by using a timer interrupt
    needed
    Software: AVR-GCC to compile
    needed
    Hardware: ATS90S8515/8535/2313/mega on STK200/300 board
    Note:     To contact me, mail to
                  volkeroth@gmx.de
              You might find more AVR related stuff at my homepage:
                    <a href=http://members.xoom.com/volkeroth target=_blank>    </a>  
*/

#include <io.h>
#include <interrupt.h>
#include <signal.h>

unsigned char led;


SIGNAL(SIG_OVERFLOW0)        /* signal handler for tcnt0 overflow interrupt */
{
    outp(~led, PORTB);       /* invert the output since a zero means: LED on */
    led <<= 1;               /* move to next LED */
    if (!led)                /* overflow: start with Port B0 again */
        led = 1;
    outp(0, TCNT0);          /* reset counter to get this interrupt again */
}


int main(void)
{
    outp(0xff,DDRB);         /* use all pins on PortB for output */

    outp((1<<TOIE0), TIMSK); /* enable TCNT0 overflow */
    outp(0,   TCNT0);        /* reset TCNT0 */
    outp(5,   TCCR0);        /* count with cpu clock/1024 */

    led = 1;                 /* init variable representing the LED state */
    sei();                   /* enable interrupts */
    for (;;) {}              /* loop forever */
}

  
2楼:xyzwp2000 2002年5月10日10:02
 0007中断输入口找不到,中断屏蔽都已打开
  
3楼:guest 2004年10月6日10:13
 计数器还有控制寄存器
计数器还有控制寄存器,控制中断是否开
再设置一下吧。
看到你的帖子已经很晚了,呵呵

>>>>>>对该主题发表你的看法

本主题贴数3,分页: [第1页]


[上一篇主题]:硬件:二氧化碳、氧气传感器急救!

[下一篇主题]:AVR单片机:IAR C compiler for 8x96