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

📄 main1.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)
	{
		T0PR = 99;			  //定时器分频,得120000HZ
		T0MCR = 0X03;		  //匹配通道0匹配中断并复位T0TC
		T0MR0 = 1200;   //   比较值(1s定时)
		T0TCR = 0X03;		//	启动并复位
		T0TCR = 0X01;		//	启动并复位
	}  
	
	void delay(int n)
	{
	    int i,j; 
		for(i = 0; i < n; i++)
		{
			for(j = 0;j < 10000; j++)
			{
			}
		}
			
	}                        
	

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

   //测试GPI/O 口
  IODIR1 = 0X00700000;//输出方式
  IOSET1 = 0X00300000;//对应位输出高
  IOCLR1 = 0X00400000;//对应位输出低


   //定时器测试
  // IODIR1 = 0X00700000;//输出方式
   time0Init();
 /*  while(1)
   {
   	  IOCLR1 = 0X00600000;//对应位输出低
      delay(10);
      IOSET1 = 0X00600000;
        delay(10);
      
   }
   */
	
	  IOSET1 = 0X00700000;//对应位输出高
   
   		while(1)
   		{
   			while((T0IR & 0x01) == 0);
   			T0IR = 0x01;
   			
   			if( (IOSET1 & 0X00700000) == 0)
			{
				IOSET1 = 0X00700000;	
			}
			else
			{
				IOCLR1 = 0X00700000;
			}
   		}

		
   

}   
                       // 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 + -