⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 周立功arm7(lpc2104)的工程模板
💻 C
字号:

// *********************************
// LPC2000 SYSTEM WITHOUT OS
// FILE:     MAIN.C
// MODIFIED: ZPCYP 2005-3-16 20:16
// *********************************
//定时器输出方波,中断方式

#include <stdio.h>
#include "lpc22xx.h"
#include "init_c.h"
#include "vic.h"
#include "eint.h"
#include "main.h"


//extern short adc_data[];

int index;
void sample(void);

void time0Init(void);
 

	 /*
	   定时器初始化程序
	  */

  void  __irq   IRQ_Time0(void)

{
	    if( (IOSET1 & 0x00700000) == 0)
		{
			IOSET1 = 0x00700000;	
		}
		else
		{
			IOCLR1 = 0x00700000;
		}
	
		 T0IR = 0x01;//清中断标志位
		VICVectAddr = 0x00;//通知VIR中断处理结束
		
}

 void time0Init(void)
{

		

		T0PR = 0x00;			  //定时器分频,得120000HZ
		T0MCR = 0x03;		  //匹配通道0匹配中断并复位T0TC
		T0MR0 = 1200;   //   比较值(1s定时)
		T0TCR = 0x03;		//	启动并复位
		T0TCR = 0x01;		//	启动并复位

		/*设置定时器0中断IRQ*/
		VICIntSelect = 0x00;//所有中断通道设置为IRQ中断
		VICVectCntl0 = 0x24;//定时器0中断通道分配最高优先级(向量控制器0)
		VICVectAddr0 = (unsigned int)IRQ_Time0;
		VICIntEnable = 0x00000010 ;//使能定时器0中断
}   

                        
	

int main(void) 
{
  char ch;
  int ctc1, ctc2;
  int x;
  x =1 ;

   //测试GPI/O 口	11110000
  IODIR0 = 0X000000f0;//输出方式
  IOSET0 = 0X00100050;//对应位输出高
  IOCLR0 = 0X006000a0;//对应位输出低
  

   //定时器测试
  /* IODIR1 = 0x00700000;//输出方式
   time0Init();
 
  */
   while(1);

	
}   
  
                       // Init target board
//  isr_eint0_init();                           // Init EINT0
/*
  IODIR0 = 1<<6;

  for (x=0;x<ADC_DATA_CNT;x++) {
    adc_data[x] = 0;
  }
  for (x=0;x<ADC_DATA_CNT;x++) {
    if (adc_data[x] != 0) {
      printf("\nWrong 1 at %d!", x);
    }
  }
  printf("\nCheck 1 done.");
  for (x=0;x<ADC_DATA_CNT;x++) {
    adc_data[x] = 123;
  }
  for (x=0;x<ADC_DATA_CNT;x++) {
    if (adc_data[x] != 123) {
      printf("\nWrong 2 at %d!", x);
    }
  }
  printf("\nCheck 2 done.");
  */

/* 
  while (1) {

    do {
      printf("\nMax1200 ADC system ready. Press 'g' to go, 't' to transmit...");
      ch = getchar();
    } while (ch != 'g' && ch != 't');

    if (ch == 'g') {
/*    
      printf("\nRunning...");
      index = 0;

      EXTINT = 0x01;                            // Clear previous EINT0
      vic_irq_enable(VIC_CH_EINT0, 1);          // Enable EINT0

      while (index < ADC_DATA_CNT);             // Wait till finished
    
      printf("Done.\n");
*/
	/*
      printf("\nRunning...");
      index = 0;
	}
  }
}
*/




/*
  ctc1 = CTC;
      sample();
  ctc2 = CTC;

  ctc2 -= ctc1;
  if (ctc2<0) ctc2+=65536;

  printf("Time: %d\n", ctc2);

printf("Done1...");

for (index=0;index<10000;index++);
      index = 0;

*/
/*
  x = 0;
  ctc1 = CTC;

      do {

        while ((IOPIN0 & (1<<16)) == 0) x++;
        adc_data[index] = (*((volatile short *) 0x82000000));
        while ((IOPIN0 & (1<<16)) == (1<<16)) x++;
      } while (++index < ADC_DATA_CNT);

  ctc2 = CTC;
  ctc2 -= ctc1;
  if (ctc2<0) ctc2+=65536;

  printf("\nTime: ********************************************%d\n", ctc2);
  printf("X: ###############################################%u\n", x);

      printf("Done2.\n");

    } else {

      for (index = 0; index < ADC_DATA_CNT; index++) {
        printf("%7d,", adc_data[index]);
      }

      printf("\nTransmit done.\n");

    }
  }
}
*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -