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

📄 lab1.c

📁 该程序源码是基于dsPIC单片机的无刷电机驱动程序。
💻 C
字号:
/*
Lab1.c is the first lab in 865 SNS.  It is a simple lab to
show how to program and run the BLDC MC board firmware using 
dsPIC2010.  
The program blinks Led D1 at a 1 hz rate.  
Steps:  
1. Complile the Lab using Project -> Build All
2. If there are no errors, Close DIP switches then ..
3. Program device using Debugger -> Program
4. If there are no errors during programming then ..,
5. Open DIP swithes and Run using Debugger -> Run
6. The Led, D1 should blink at a 1 Hz rate. 
*/

#define __dsPIC30F2010__
#include "E:\Program Files\Microchip\MPLAB C30\support\h\p30F2010.h"

#define FCY  5000000				// xtal = 5.0Mhz; PLLx4
#define MILLISEC FCY/10000		// 1 mSec delay constant

#define D1 LATCbits.LATC13		// RC13 is Led D1



void DelayNmSec(unsigned int N);



int main(void)
{

	LATC = 0x0000;
	TRISC = 0xDFFF;			// RC13 as output for LED D1
	while(1)						// do for ever
	{
			DelayNmSec(500);	// wait for 500 mSecs
			D1 = !D1;			// toggle Led D1
	}	// end of while (1)

}
	

//---------------------------------------------------------------------
// This is a generic 1ms delay routine to give a 1mS to 65.5 Seconds delay
// For N = 1 the delay is 1 mS, for N = 65535 the delay is 65,535 mS. 
// Note that FCY is used in the computation.  Please make the necessary
// Changes(PLLx4 or PLLx8 etc) to compute the right FCY as in the define
// statement above.

void DelayNmSec(unsigned int N)
{
unsigned int j;
while(N--)
 	for(j=0;j < MILLISEC;j++);
}

⌨️ 快捷键说明

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