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

📄 pwm(adjust).txt

📁 实现pwm的频率和占空比可调
💻 TXT
字号:
//======================================================
//	The information contained herein is the exclusive property of
//	Sunnnorth Technology Co. And shall not be distributed, reproduced,
//	or disclosed in whole in part without prior written permission.
//	(C) COPYRIGHT 2003  SUNNORTH TECHNOLOGY CO.
//	ALL RIGHTS RESERVED
//	The entire notice above must be reproduced on all authorized copies.
//========================================================
//============================================================
//	工程名称:	SDCardDriver
//	功能描述:	61板与SD卡相连
//				实现SD卡的读、写、擦除扇区操作
//				使用变量查看WriteBuf和ReadBuf可观察到执行效果
//	涉及的库:	CMacro.lib
//				clib.lib
//				SDDriver_061A.lib
//	组成文件:	main.c,				
//				.\SD\SD_Hardware.asm, .\SD\SD_CFG.inc, .\SD\SD_Hardware.h,.\SD\SD_Command.h,.\SD\SD_CRC.h
//				.\SD\SD_Driver.h,.\SD\SD_INC.h
//
//				.\System\ISR.asm
//	硬件连接:	将SD卡座模组插接到61板的IOB口的低八位
//	维护记录:	2007-5-14 v1.0
//===============================================

#include ".\SD\SD_Driver.h"
#include ".\SD\SD_Hardware.h"
#include".\SD\SD_INC.h"

unsigned char ReadBuf[512];
unsigned char WriteBuf[512];

int main()
{
	unsigned int i,ret;
	while(SD_Initialize() != SD_NO_ERR)
		*P_Watchdog_Clear = 0x0001; 		// 等待SD卡初始化成功完成
	for(i = 0; i < 512; i++)
	{
		WriteBuf[i] = i; 					// 给缓冲区赋初值
		*P_Watchdog_Clear = 0x0001;
	}
	ret = SD_WriteBlock(10, WriteBuf); 		// 将缓冲区WriteBuf内容写入SD卡的10号Block
	ret = SD_WriteBlock(11, WriteBuf); 		// 将缓冲区WriteBuf内容写入SD卡的11号Block
	if(ret!= SD_NO_ERR)
	{
		while(1)
			*P_Watchdog_Clear = 0x0001; 	// 写入发生错误
	}
	ret = SD_ReadBlock(10, ReadBuf); 		// 将SD卡的10号Block内的数据读出,并保存至ReadBuf
	if(ret != SD_NO_ERR)
	{
		while(1)
			*P_Watchdog_Clear = 0x0001; 	// 读取发生错误
	}
	for(i = 0; i < 512; i++)				//比较读出的数据和写入的数据是否一致
	{
		if(i != WriteBuf[i])
		{
			while(1)
				*P_Watchdog_Clear = 0x0001;	// 读出的数据与写入的不一致
		}
	}
	SD_EraseBlock(10,2);					//擦除从10号扇区开始的2个扇区,即10号11号
	ret = SD_ReadBlock(11, ReadBuf); 		// 将SD卡的11号Block内的数据读出,并保存至ReadBuf
	if(ret != SD_NO_ERR)
	{
		while(1)
			*P_Watchdog_Clear = 0x0001; 	// 读取发生错误
	}
	return 0;
}

⌨️ 快捷键说明

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