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

論壇索引


Board index » All Posts (秋雨)




Re: 關於PIC24FJ16GA002系列問題
#1
新會員
新會員


拿到的就是有Bug的版本
Target Device PIC24FJ16GA002 found, revision = Rev 0x3003

目前I2C上週就有依照ERRATA文件寫的來測試
Master I2C1是沒問題的

目前測試I2C1 Master -> I2C2 Slave



發表於: 2009/2/10 11:57
頂部


關於PIC24FJ16GA002系列問題
#2
新會員
新會員


PIC24FJ16GA002有些硬體方面的問題
請問一下Microchip目前新生產CHIP有對PIC24FJ16GA002
做硬體修正嗎 ?

發表於: 2009/2/6 16:58
頂部


Re: I2C SCL 訊號一問
#3
新會員
新會員


感謝你熱請的說明
我那個I2C因該是PIC IC問題
如果有用PIC24FJXXGAXXX
可以去看我最後說明的地方
^_^

發表於: 2009/2/5 9:41
頂部


Re: 關於PIC24F 使用I2C 存取EEPROM
#4
新會員
新會員


目前測試結果為PIC24FJ16GA002的問題
使用4.7K Pull High電阻拉I2C
Chip本身會發生I2C衝突問題
使用10K Pull High電阻拉I2C
目前不會發生I2C衝突問題

依據國外論壇說明的SDA腳位再INIT I2C後
需在拉Low SCL才會正常動作

所以建議有使用PIC24FJ16GA002的朋友犧牲一支腳位
在INIT I2C後將拉SDA拉LOW確保I2C會作用正常

http://forum.microchip.com/tm.aspx?m= ... ey=PIC24FJ16GA002񅪟

發表於: 2009/2/4 14:12
頂部


Re: I2C SCL 訊號一問
#5
新會員
新會員


有目前都接回來了
也有接4.7K的提升電阻
但是都是在HI準位不會動作

發表於: 2009/1/23 17:17
頂部


Re: I2C SCL 訊號一問
#6
新會員
新會員


我使用的IC是PIC24FJ16GA002
MPLAB IDE Ver:8.1
C30:V1.32
版主給的那份SAMPLE CODE我同事已經有
早上有改來測試
有接一個24lc21a EEPROM
有時候有訊號輸出有時候無訊號輸出

目前想說將問題單純化把連接EEPROM的腳位移除
不接SCL SDK 先使用示波器確定訊號輸出是對的
再接EEPROM,結果反而沒有訊號輸出

請問如果IC腳位空接可以嗎?

發表於: 2009/1/23 15:48
頂部


Re: I2C SCL 訊號一問
#7
新會員
新會員


IC燒掉
換了一個IC後又不會動作
設成Input port訊號完全看不見

發表於: 2009/1/22 15:39
頂部


Re: I2C SCL 訊號一問
#8
新會員
新會員


你因該是跟我一樣
沒把SCL2跟SDA2定義為輸出腳位吧

發表於: 2009/1/21 14:15
頂部


Re: 關於PIC24F 使用I2C 存取EEPROM
#9
新會員
新會員


經過修正目前有訊號產生,不過還是寫不進EEPROM
原因:
原來是Sample code 沒將I2C腳位定義為輸出腳位
這樣因該不能算是Sample code吧
第一次用MicroChip 的人因該都不知道怎樣修改吧
以為SampleCode就會動作下載下來卻不能動作

// calculate baud rate of I2C
#define Fosc (20000000)
#define Fcy (Fosc/2) // no PLL
#define Fsck 100000
#define I2C_BRG ((Fcy/Fsck)-2)//依據SPEC修正
((Fcy/2/Fsck)-1)//Sample Code
int main (void)
{
...
PADCFG1=0xffff;
TRISBbits.TRISB6 = 0;//定義為輸出腳位
LATBbits.LATB6 = 0;

TRISBbits.TRISB8 = 0;//定義為輸出腳位 SDA1
// LATBbits.LATB8 = 0;
TRISBbits.TRISB9 = 0;//定義為輸出腳位SCL1
// LATBbits.LATB9 = 0;
}

發表於: 2009/1/21 12:13
頂部


關於PIC24F 使用I2C 存取EEPROM
#10
新會員
新會員


使用Sample code 利用I2C對PIC24F系列讀寫EEPROM
可是腳位都不會動作,請問一下使用PIC24F有遇到相同問題嗎?

#include "p24fxxxx.h"

#define USE_AND_OR // To enable AND_OR mask setting for I2C.
#include <i2c.h>

// JTAG/Code Protect/Write Protect/Clip-on Emulation mode
// Watchdog Timer/ICD pins select
_CONFIG1(JTAGEN_OFF & GCP_OFF & GWRP_OFF & COE_OFF & FWDTEN_OFF & ICS_PGx1)
// Disable CLK switch and CLK monitor, OSCO or Fosc/2, HS oscillator,
// Primary oscillator
_CONFIG2(FCKSM_CSDCMD & OSCIOFNC_OFF & POSCMOD_HS & FNOSC_PRI)

#define lenArray(arr) (sizeof(arr)/sizeof(arr[0]))

// calculate baud rate of I2C
#define Fosc (20000000) //8000000
#define Fcy (Fosc/2) // no PLL
#define Fsck 100000
#define I2C_BRG ((Fcy/Fsck)-1)//((Fcy/2/Fsck)-1)

#define I2C_EEPROM_2402 // use 24XX02X, Low Address only
//#define I2C_EEPROM_24256 // use 24XX256, HiLo Address


void i2c_wait(unsigned int cnt)
{
while(--cnt)
{
asm( "nop" );
asm( "nop" );
}
}

int main (void)
{
unsigned char SlaveAddress;
char i2cData[10];
int DataSz;
int Index = 0;
unsigned char *pWrite, *pRead;
unsigned int qqq;

// The data to be written should be end with '\0' if using
// char MasterputsI2C1(unsigned char *) library function.
unsigned char tx_data[] = {'P', 'I', 'C', '2', '4', 'F', '\0'};

unsigned char rx_data[lenArray(tx_data)];
char status;
unsigned char i2cbyte;

PADCFG1=0xffff;
TRISBbits.TRISB6 = 0;
LATBbits.LATB6 = 0;


pWrite = tx_data;
pRead = rx_data;

//Enable channel
OpenI2C1( I2C_ON, I2C_BRG );

I2C1STATbits.ACKSTAT = 1;

qqq = ((I2C1STAT&I2C1STATbits.ACKSTAT)==I2C1STATbits.ACKSTAT);

SlaveAddress = 0x50; //0b1010000 Serial EEPROM address




// Send Data to eeprom to program one location
#ifdef I2C_EEPROM_24256 // one page is 64 bytes
i2cData[0] = (SlaveAddress << 1) | 0; //Device Address & WR
i2cData[1] = 0x05; //eeprom high address byte
i2cData[2] = 0x40; //eeprom low address byte
i2cData[3] = 0xAC; //data to write
DataSz = 4;
#endif
#ifdef I2C_EEPROM_2402 // one page is 8 bytes
i2cData[0] = (SlaveAddress << 1) | 0; //Device Address & WR
i2cData[1] = 0x10;
//eeprom low address byte
i2cData[2] = 0xAC; //data to write (one byte)
DataSz = 3;
#endif

/*
* Write one byte to designated address. [1]
*/
LATBbits.LATB6 = 1;
StartI2C1(); //Send the Start Bit
IdleI2C1(); //Wait to complete

while( DataSz )
{
MasterWriteI2C1( i2cData[Index++] );
IdleI2C1(); //Wait to complete

DataSz--;

//ACKSTAT is 0 when slave acknowledge,
//if 1 then slave has not acknowledge the data.
qqq = I2C1STATbits.ACKSTAT;
if( I2C1STATbits.ACKSTAT )
break;
}
// one byte has been written

// write some bytes continuously
// The data to be written should be end with '\0' if using
// char MasterputsI2C1(unsigned char *) library function.
status = MasterputsI2C1(pWrite);
Nop();

if (status == -3)
while (1);

StopI2C1(); //Send the Stop condition
IdleI2C1(); //Wait to complete
LATBbits.LATB6 = 0;
/*
* End writing. [1]
*/

#if 0
while(1)
{
DDCCI_Handler
}
#endif
// wait for eeprom to complete write process. poll the ack status


while(1)
{
i2c_wait(10);
LATBbits.LATB6 = 1;
StartI2C1(); //Send the Start Bit
IdleI2C1(); //Wait to complete

MasterWriteI2C1( i2cData[0] );
IdleI2C1(); //Wait to complete

if( I2C1STATbits.ACKSTAT == 0 ) //eeprom has acknowledged
{
StopI2C1(); //Send the Stop condition
IdleI2C1(); //Wait to complete
LATBbits.LATB6 = 0;
break;
}

StopI2C1(); //Send the Stop condition
IdleI2C1(); //Wait to complete
LATBbits.LATB6 = 0;
}


/********************************************************************/
/*
* Now Readback one data from the serial eeprom. [2]
*/
#ifdef I2C_EEPROM_24256
i2cData[0] = (SlaveAddress << 1) | 0; //Device Address & WR
i2cData[1] = 0x05; //eeprom high address byte
i2cData[2] = 0x40; //eeprom low address byte
DataSz = 3;
#endif
#ifdef I2C_EEPROM_2402
i2cData[0] = (SlaveAddress << 1) | 0; //Device Address & WR
i2cData[1] = 0x10; //eeprom low address byte
DataSz = 2;
#endif

LATBbits.LATB6 = 1;
StartI2C1(); //Send the Start Bit
IdleI2C1(); //Wait to complete

//send the address to read from the serial eeprom
Index = 0;
while( DataSz )
{
MasterWriteI2C1( i2cData[Index++] );
IdleI2C1(); //Wait to complete

DataSz--;

// ACKSTAT is 0 when slave acknowledge,
// if 1 then slave has not acknowledge the data.
if( I2C1STATbits.ACKSTAT)
break;
}

//now send a start sequence again
RestartI2C1(); //Send the Restart condition
i2c_wait(10);
//wait for this bit to go back to zero
IdleI2C1(); //Wait to complete

MasterWriteI2C1( (SlaveAddress << 1) | 1 ); //transmit read command
IdleI2C1(); //Wait to complete

i2cbyte = MasterReadI2C1(); // read one byte

StopI2C1(); //Send the Stop condition
IdleI2C1(); //Wait to complete
LATBbits.LATB6 = 0;
/*
* End reading one byte. [2]
*/
// verify write and read I2C EEPROM (single byte)
if( i2cbyte != 0xAC )
while(1); //error: verify failed

/********************************************************************/
/*
* Now Readback several data from the serial eeprom. [3]
*/
#ifdef I2C_EEPROM_24256
i2cData[0] = (SlaveAddress << 1) | 0; //Device Address & WR
i2cData[1] = 0x05; //eeprom high address byte
i2cData[2] = 0x41; //eeprom low address byte
DataSz = 3;
#endif
#ifdef I2C_EEPROM_2402
i2cData[0] = (SlaveAddress << 1) | 0; //Device Address & WR
i2cData[1] = 0x11; //eeprom low address byte
DataSz = 2;
#endif

LATBbits.LATB6 = 1;
StartI2C1(); //Send the Start Bit
IdleI2C1(); //Wait to complete

//send the address to read from the serial eeprom
Index = 0;
while( DataSz )
{
MasterWriteI2C1( i2cData[Index++] );
IdleI2C1(); //Wait to complete

DataSz--;

// ACKSTAT is 0 when slave acknowledge,
// if 1 then slave has not acknowledge the data.
if( I2C1STATbits.ACKSTAT )
break;
}

//now send a start sequence again
RestartI2C1(); //Send the Restart condition
i2c_wait(10);
//wait for this bit to go back to zero
IdleI2C1(); //Wait to complete

MasterWriteI2C1( (SlaveAddress << 1) | 1 ); //transmit read command
IdleI2C1(); //Wait to complete

// read some bytes back
status = MastergetsI2C1(lenArray(tx_data), pRead, 20);

if (status!=0)
while(1);

StopI2C1(); //Send the Stop condition
IdleI2C1(); //Wait to complete
LATBbits.LATB6 = 0;
/*
* End reading several bytes. [3]
*/

// verify write and read I2C EEPROM (multiple bytes)
Index = 0;
do {
if(*pRead++ != *pWrite++)
while(1); //error: verify failed
Index++;
} while(Index<lenArray(tx_data)-1);

while(1); // Success

return 0;
}

發表於: 2009/1/20 15:14
頂部



(1) 2 »



:::

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... ]

教育訓練中心

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