导航: 老古网老古论坛XMOS公共讨论区XMOS开源项目区单片机程序设计嵌入式系统广告区域
→AVR单片机:晓奇,进来看看,好吗?

* 11221: AVR单片机:晓奇,进来看看,好吗?

   huangxi205 
huangxi205发表的帖子 

 AVR单片机:晓奇,进来看看,好吗?
晓奇,帮我看看我下面的程序好吗?我知道你是高手,麻烦多多指教。怎么PC口输出的频
率只有24K对哦一点点?PD.7 输出间隔也不对,大概有五六十秒,请帮我看看我的程序错
在那里,非常多谢!!!!!
/*********************************************
Chip type           : AT90S8535
Clock frequency     : 4.000000 MHz
Memory model        : Small
Internal SRAM size  : 512
External SRAM size  : 0
Data Stack size     : 128
*********************************************/

#include <90s8535.h>
#include <delay.h>

// Timer 0 overflow interrupt service routine
interrupt [TIM0_OVF] void timer0_ovf_isr(void)
{
// Reinitialize Timer's 0 value
TCNT0=0xfc;
PORTC=~PORTC;

}

// Declare your global variables here

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

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

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

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

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

// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: 4000.000 kHz
// Mode: Output Compare
// OC0 output: Disconnected
TCCR0=0x01;
TCNT0=0xfc;

// 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;

// Timer/Counter 2 initialization
// Clock source: System Clock
// Clock value: Timer 2 Stopped
// Mode: Output Compare
// OC2 output: Disconnected
TCCR2=0x00;
ASSR=0x00;
TCNT2=0x00;
OCR2=0x00;

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

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

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

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

while (1)
      {
      delay_ms(500);
      PORTD.7=!PORTD.7;

      };
}


发表时间:2002年9月19日10:48:00

  
回复该帖

本主题共有 1 帖,分页:>>>>>该主题的所有内容[1]条

 *树形目录 只列出部分跟帖的标题以及简单的摘要信息 该主题的部分跟帖如下:

[上一篇帖子]:已经发给你了
[下一篇帖子]:C51编程:谁有PC和51的485通信程序?qgque@163.com