• slider image 442
  • slider image 483
  • slider image 484
  • slider image 485
  • slider image 486
  • slider image 487
  • slider image 488
  • slider image 491
:::


Browsing this Thread:   1 Anonymous Users






93lc66b怎样使用?看我的调用文件有什么问题
#1
新會員
新會員


查看用戶資訊
///////////////////////////////////////////////////////////////////////////
//// Library for a MicroChip 93C66B configured for a x16 org ////
//// ////
//// init_ext_eeprom(); Call before the other functions are used ////
//// ////
//// write_ext_eeprom(a, d); Write the byte d to the address a ////
//// ////
//// d = read_ext_eeprom(a); Read the byte d from the address a ////
//// ////
//// The main program may define eeprom_select, eeprom_di, eeprom_do ////
//// and eeprom_clk to override the defaults below. ////
//// ////
///////////////////////////////////////////////////////////////////////////
//// (C) Copyright 1996,2003 Custom Computer Services ////
//// This source code may only be used by licensed users of the CCS C ////
//// compiler. This source code may only be distributed to other ////
//// licensed users of the CCS C compiler. No other use, reproduction ////
//// or distribution is permitted without written permission. ////
//// Derivative programs created using this software in object code ////
//// form are not restricted in any way. ////
///////////////////////////////////////////////////////////////////////////

#ifndef EEPROM_SELECT

#define EEPROM_SELECT PIN_C0
#define EEPROM_CLK PIN_C1
#define EEPROM_DI PIN_C2
#define EEPROM_DO PIN_C3

#endif

#define EEPROM_ADDRESS long int
#define EEPROM_SIZE 512

#define hi(x) (*(&x+1))


void init_ext_eeprom() {
BYTE cmd[2];
BYTE i;

output_low(EEPROM_DI);
output_low(EEPROM_CLK);
output_low(EEPROM_SELECT);

cmd[0]=0xc0;
cmd[1]=0x4;

for(i=1;i<=5;++i)
shift_left(cmd,2,0);
output_high(EEPROM_SELECT);
for(i=1;i<=11;++i) {
output_bit(EEPROM_DI, shift_left(cmd,2,0));
output_high(EEPROM_CLK);
output_low(EEPROM_CLK);
}
output_low(EEPROM_DI);
output_low(EEPROM_SELECT);
}


void write_ext_eeprom(EEPROM_ADDRESS address, long data) {
BYTE cmd[3];
BYTE i;

cmd[0]=data;
cmd[1]=(BYTE)address;
cmd[2]=0xa|hi(address);

for(i=1;i<=4;++i)
shift_left(cmd,3,0);
output_high(EEPROM_SELECT);
for(i=1;i<=27;++i) {
if(i==4)
output_high(EEPROM_SELECT);
output_bit(EEPROM_DI, shift_left(cmd,3,0));
output_high(EEPROM_CLK);
output_low(EEPROM_CLK);
}
output_low(EEPROM_DI);
output_low(EEPROM_SELECT);
delay_ms(11);
}


BYTE read_ext_eeprom(EEPROM_ADDRESS address) {
BYTE cmd[3];
BYTE i;
long data;

cmd[0]=0;
cmd[1]=(BYTE)address;
cmd[2]=0xc|hi(address);

for(i=1;i<=4;++i)
shift_left(cmd,3,0);
output_high(EEPROM_SELECT);
for(i=1;i<=27;++i) {
output_bit(EEPROM_DI, shift_left(cmd,3,0));
output_high(EEPROM_CLK);
output_low(EEPROM_CLK);
if(i>11)
shift_left(&data,1,input(EEPROM_DO));
}
output_low(EEPROM_SELECT);
return(data);
}

發表於: 2006/9/2 13:36
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部







You can view topic.
不可以 發起新主題
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.

[進階搜尋]


:::

Microchip連結

https://www.facebook.com/microchiptechnologytaiwan/
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=13
https://mu.microchip.com/page/tmu
http://elearning.microchip.com.tw/modules/tad_link/index.php?cate_sn=1
https://page.microchip.com/APAC-PrefCenters-TW.html
http://www.microchip.com/
http://www.microchip.com/treelink
http://www.microchipdirect.com/
http://www.microchip.com.cn/newcommunity/index.php?m=Video&a=index&id=103
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=2
http://www.microchip.com.tw/Data_CD/eLearning/index.html
http://www.microchip.com.tw/RTC/RTC_DVD/
https://www.microchip.com/development-tools/
https://www.youtube.com/user/MicrochipTechnology
[ more... ]

教育訓練中心

!開發工具購買
辦法說明 [業界客戶] [教育單位]
----------------------------------
!校園樣品申請
辦法說明 [教師資格] [學生資格]
----------------------------------