• 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






Re: I2C讀取溫度感測器的問題
#8
版主
版主


查看用戶資訊
看你的程式,我想你還是沒有了解到 dsPIC I2C Module 的動作需求,I2C 的軟體動作沒有你所寫的那麼簡單。建議你還是先看一下 dsPIC30F Peripheral Training 裡的 I2C 教育訓練,並參考裡面的 I2C Master 的範例程式。

發表於: 2008/10/20 11:34
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: I2C讀取溫度感測器的問題
#7
新會員
新會員


查看用戶資訊
有參考過資料了~
覺得我打的程式應該是沒有問題~~
不過不知道會什麼tmp423還是不回應我 = =

#define _dsPIC33FJ256GP710_
#include <p33FJ256GP710.h>
#include <i2c.h>

void main()
{
TRISA=0;
ODCGbits.ODCG2=1;
ODCGbits.ODCG3=1;
PORTGbits.RG3=1;
PORTGbits.RG2=1;
I2C1CONbits.I2CEN=1;
I2C1CONbits.SMEN=1;
while (1)
{
I2C1CONbits.SEN=1; //start
I2C1ADD=10011000; //傳送Slave Address Byte~~
while (I2C1STATbits.ACKSTAT=0)
{
I2C1TRN=0x0A; //傳送Pointer Register Byte
while (I2C1STATbits.ACKSTAT=0)
{
I2C1CONbits.PEN=1; //stop

I2C1CONbits.SEN=1; //start
I2C1ADD=10011001; //傳送Slave Address Byte
while (I2C1STATbits.ACKSTAT=0)
{
PORTA=I2C1RCV; //把接收的值放進porta用跑馬燈顯示
while (I2C1STATbits.ACKSTAT=0)
{
I2C1CONbits.PEN=1; //stop
}
}
}
}
}
}



照理來說應該會動阿@@
還是我還有缺少什麼設定??
看了動作圖~i2c應該這樣設定就會動作了吧??

順便附上tmp423的datasheet

Attach file:


Link only for registered users

發表於: 2008/10/20 9:53
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: I2C讀取溫度感測器的問題
#6
版主
版主


查看用戶資訊
不行的,I2C 沒有這麼簡單。你可以先參考一下 W401 C18 得教材第六章的說明。或參考dsPIC30F Peripheral Training 教育訓練裡的 I2C 章節。右上角可以搜尋到。

發表於: 2008/10/13 9:37
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: I2C讀取溫度感測器的問題
#5
新會員
新會員


查看用戶資訊
看了datasheet。
SDA,和SCL這兩隻腳應該是要先高電位送出
所以下面這兩隻腳設唯1應該沒錯吧~~
PORTGbits.RG3=1;
PORTGbits.RG2=1;
while (1)
{
tmp的datasheet說如果要偵測內部溫度,就只讓送出0X08就可以開啟偵測內部溫度的功能了,所以把值放在這邊應該沒錯吧?
I2C1MSK=0x08;
PORTGbits.RG3=0;
^^^^^讓SDA變成低電位啟動I2C
if(I2C1STATbits.RBF=1)
{
PORTA=I2C1RCV;
PORTGbits.RG3=1;
^^^^資料傳送完在讓SDA變成高電位,關閉I2C
}
}
}

想要問一下是不是這樣就能讓I2C動作了呢?

發表於: 2008/10/13 9:07

Edited by iceborns on 2008年10月13日 09:41:01
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: I2C讀取溫度感測器的問題
#4
新會員
新會員


查看用戶資訊
謝謝兩位大大~

我來研究一下你們給的網頁

發表於: 2008/10/8 14:29
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: I2C讀取溫度感測器的問題
#3
新會員
新會員


查看用戶資訊
這有兩個I2C參考資料...先看看吧
TMP423 datasheet裡面的BUS OVERVIEW的章節也先看過一次

http://zh.wikipedia.org/wiki/I2C

http://designer.mech.yzu.edu.tw/article/articles/course/file/(2005-06-06)%20PIC_SERVER%E6%95%99%E6%9D%90(14)%EF%BC%8DPIC%E5%96%AE%E6%99%B6%E7%89%87I2C%E9%80%9A%E8%A8%8A%E7%B0%A1%E4%BB%8B%E8%88%87%E5%AF%A6%E4%BE%8B.pdf

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


Re: I2C讀取溫度感測器的問題
#2
版主
版主


查看用戶資訊
1. TMP423 是 TI 的 I2C 溫度感應器,所以你必須先知道 I2C 的規範。

2. 從你的程式看來,你對 I2C 的觀念不是很清楚這樣要怎樣寫程式?

所以我會建議先下載一下 I2C 的規格 (到 NXP 網站) 先了解一下 I2C 的通訊協定吧!

發表於: 2008/10/7 8:36

Edited by Ryang on 2008年10月07日 08:54:50
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


I2C讀取溫度感測器的問題
#1
新會員
新會員


查看用戶資訊
我用dsPIC33FJ256GP710寫了程式要來讀取TMP423這顆溫度感測器的溫度資料~~~但是怎麼好像也都不會動
麻煩大大幫我看一下哪裡出了問題

#define _dsPIC33FJ256GP710_
#include <p33FJ256GP710.h>

int i;
void main()
{
ODCGbits.ODCG2=1;
ODCGbits.ODCG3=1;
I2C1CONbits.I2CEN=1;
I2C1CONbits.RCEN=1;
I2C1CONbits.ACKDT=1;
I2C1CONbits.ACKEN=1;
I2C1CONbits.A10M=0;
LATGbits.LATG3=0;
LATGbits.LATG2=1;
IFS0bits.IC2IF = 0;
while (1)
{
PORTGbits.RG1=0;
I2C1MSK=0x01;
while(I2C1STATbits.RBF=1);
{
PORTA=I2C1RCV;
DelayX1ms(800);
}
}
}

void DelayX1ms(unsigned int count)
{
unsigned int i,j;
for(i=0;i<count;i++)
for(j=0;j<114;j++);
}

發表於: 2008/10/6 20:53
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... ]

教育訓練中心

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