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


Browsing this Thread:   1 Anonymous Users






Re: 關於I2C的程式
#4
新會員
新會員


查看用戶資訊
感謝各位大大~
問題找到了~
原因是....PIC壞掉了...Orz

發表於: 2005/8/10 23:58
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 關於I2C的程式
#3
高級會員
高級會員


查看用戶資訊
1. 先不用 ICD2 看看編譯有問題嗎
2. 試試 ICD2 連線是否正常
3.隨便燒錄一個程式 看看是否 ICD2 正常
4. IC 設定值有確認了嗎
5. Erase IC 再燒錄
6.換一顆IC 試試
7.換一個 ICD2 試試

看起來 像是 燒錄失敗


發表於: 2005/8/10 22:32
IWC
IWC
JL
Rolex


PP
有點距離
越來越遠
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 關於I2C的程式
#2
資深會員
資深會員


查看用戶資訊
project 中所加入的.lkr檔,是不是mcc18底下的18f452i.lkr呢?

其中的 'i' 代表適合ICD2使用;使用mcc18底下的,是因為搭配c18的記憶體分配。

發表於: 2005/8/10 22:32
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


關於I2C的程式
#1
新會員
新會員


查看用戶資訊
以下是I2C的程式範例
====================================
#include <p18f452.h>
#include <delays.h>

#define Write 0x00
#define Read 0x01
#define Device1 0x20

void F_Initial(void);
void F_I2C_START(void);
unsigned char F_I2C_WAIT(void);
unsigned char F_I2C_Send_Address(unsigned char,unsigned char);
void F_I2C_Send_Data(unsigned char);
void F_I2C_STOP(void);
unsigned char F_I2C_Read_Data(void);

void main(void)
{
unsigned char command=Write,UC_I2C_Data=0;
F_Initial();
while(1)
{
switch (command)
{
case Write:
F_I2C_START();
if (F_I2C_Send_Address(Device1,command))
F_I2C_Send_Data(UC_I2C_Data++);
F_I2C_STOP();
Delay10KTCYx(20);
command=Read;
break;
case Read:
F_I2C_START();
if (F_I2C_Send_Address(Device1,command))
LATD = F_I2C_Read_Data();
F_I2C_STOP();
Delay10KTCYx(20);
command=Write;
break;
default:
break;
}
}
}

void F_Initial(void)
{
TRISD = 0;
LATD = 0;
TRISCbits.TRISC3 = 0;
TRISCbits.TRISC4 = 0;
SSPSTATbits.SMP = 1;
SSPSTATbits.CKE = 0;
SSPCON1 = 0x38;
SSPADD = 0x30;
}

void F_I2C_START(void)
{
SSPCON2bits.SEN = 1;
while(!F_I2C_WAIT());
}

unsigned char F_I2C_WAIT(void)
{
if ( PIR1bits.SSPIF )
{
PIR1bits.SSPIF = 0;
return (1);
}
else
return (0);
}

unsigned char F_I2C_Send_Address(unsigned char UC_Address,unsigned char UC_RW)
{
SSPBUF = ((UC_Address & 0xFE) | UC_RW);
while(!F_I2C_WAIT());
if ( SSPCON2bits.ACKSTAT )
return (0);
else
return (1);
}

void F_I2C_Send_Data(unsigned char UC_Data)
{
SSPBUF = UC_Data;
while(!F_I2C_WAIT());
}

void F_I2C_STOP(void)
{
SSPCON2bits.PEN = 1;
while(!F_I2C_WAIT());
}

unsigned char F_I2C_Read_Data(void)
{
unsigned char UC_Temp=0;
SSPCON2bits.RCEN = 1;
while(!F_I2C_WAIT());
UC_Temp = SSPBUF;
SSPCON2bits.ACKDT = 1;
SSPCON2bits.ACKEN = 1;
while(!F_I2C_WAIT());
return ( UC_Temp );
}
====================================
各位大大~
以上程式是課本的範例,小弟在跑的時候出現了以下錯誤
ICD0161: Verify failed (MemType = Program, Address = 0x0, Expected Val = 0xEF2A, Val Read = 0x0)
ICD0275: Programming failed.

我嘗試改一些宣告,雖然compiler過了還是出現上述的錯誤
請問~究竟是那裡出錯呢?
敬請賜教!!感激不盡~~~

註:在下小弟我使用MPLAB IDE V7.10與ICD2與APP001






發表於: 2005/8/10 21:51
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... ]

教育訓練中心

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