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

📄 cpld_read._c

📁 用ICC编写的程序包括SPI
💻 _C
字号:
#include "Cpld_Read.h"
#include <macros.h>

int Cpld_Read(unsigned char Address)
{
  
  unsigned char temp;
  int 	 Result;
  CLI();
  if(Address)		   					//Address select
  	PORTB|=BIT(A0);			
  else
  	PORTB&=~BIT(A0);
  PORTB|=BIT(LoadL);					//LoadL set low
  NOP();
  NOP();
  PORTB&=~BIT(LoadL);					
  NOP();
  NOP();
  NOP();
  temp=CpldRead;						//Read Data low byte
  temp=CpldRead;
  
  PORTB|=BIT(LoadL);					//Set LoadL high
  
  PORTB|=BIT(LoadH);					//LoadH set low
  NOP();
  NOP();
  PORTB&=~BIT(LoadH);					
  NOP();
  NOP();
  NOP();
  Result=CpldRead;						//Read Data low byte
  Result=CpldRead;
  
  PORTB|=BIT(LoadH);					//LoadH set high
  
 Result=(Result<<8)+temp;
 SEI();
 
 return	 Result;
 
 }
 
 void  Cpld_Set(void)
 {
  	CLI();
	PORTB|=BIT(Set);
	NOP();
	NOP();
	PORTB&=~BIT(Set);
	NOP();
	NOP();
	NOP();
	NOP();
	NOP();
	NOP();
	PORTB|=BIT(Set);
	SEI();
}

void  Cpld_Init(void)
{	  
 PORTB|=BIT(Set);	 	 				//Set All Control signal high
 PORTB|=BIT(LoadL);
 PORTB|=BIT(LoadH);
 PORTB&=~BIT(LoadL);

}






	

⌨️ 快捷键说明

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