欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標題:
PMC234+AT24C01程序源碼
[打印本頁]
作者:
yaoyangui
時間:
2017-11-10 10:45
標題:
PMC234+AT24C01程序源碼
PMC234 + AT24C01 程序源碼,直接可用
所有資料51hei提供下載:
pmc234_24c01.rar
(17.78 KB, 下載次數: 12)
2017-11-10 10:44 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
單片機源程序如下:
#include "extern.h"
/***********************************************************************************************/
void at24cxx_Delay_5us( void );
void at24cxx_Delay_10us( void );
void at24cxx_Delay_10ms( void );
void AT24CXX_IO_Init( void );
void AT24CXX_CLK_LOW( void );
void AT24CXX_CLK_HIGH( void );
void AT24CXX_IO_LOW( void );
void AT24CXX_IO_HIGH( void );
void at24cxx_IO_input( void );
void at24cxx_IO_ouput( void );
void at24cxx_Start( void );
void at24cxx_Stop( void );
void at24cxx_SEND_ACK( void );
void at24cxx_SEND_NACK( void );
void at24cxx_RECV_ACK( void );
void at24cxx_Recv_Char( void );
void at24cxx_Send_Char( void );
void read_Random_Byte( void );
void write_Random_Byte( void );
void read_eeprom_configuration( void );
void write_eeprom_configuration( void );
/***********************************************************************************************/
void FPPA0 (void)
{
.ADJUST_IC SYSCLK=IHRC/2, IHRC=16MHz, VDD=5V, Bandgap=On;
// Insert Initial Code
AT24CXX_IO_Init();
while (1)
{
// ...
// wdreset;
read_eeprom_configuration();
write_eeprom_configuration();
}
}
void FPPA1 (void)
{
goto $;
}
void Interrupt (void)
{
pushaf;
if (Intrq.T16)
{ // T16 Trig
// User can add code
Intrq.T16 = 0;
//...
}
popaf;
}
/******************************************************/
/***********************************************************************************************
* \brief This function is just used to generate some example data for write operations
* on the card.
*
**********************************************************************************************/
void at24cxx_Delay_5us( void )
{
.delay 100;
}
void at24cxx_Delay_10us( void )
{
.delay 200;
}
void at24cxx_Delay_10ms( void )
{
.delay 200;
.delay 200;
.delay 200;
.delay 200;
.delay 200;
}
/***********************************************************************************************/
void AT24CXX_IO_Init( void )
{
//SCL
PA.0 = 1;
PAC.0 = 1;
//SDA
PA.5 = 1;
PAC.5 = 0;
}
/***********************************************************************************************/
void AT24CXX_CLK_LOW( void )
{
PA.0 = 0;
}
void AT24CXX_CLK_HIGH( void )
{
PA.0 = 1;
}
/***********************************************************************************************/
void AT24CXX_IO_LOW( void )
{
PA.5 = 0;
}
void AT24CXX_IO_HIGH( void )
{
PA.5 = 1;
}
/***********************************************************************************************
* \brief This function is just used to generate some example data for write operations
* on the card.
*
**********************************************************************************************/
void at24cxx_IO_input( void )
{
PAC.5 = 0;
}
void at24cxx_IO_ouput( void )
{
PAC.5 = 1;
}
/***********************************************************************************************
* \brief This function is just used to generate some example data for write operations
* on the card.
*
**********************************************************************************************/
/***********************************************************************************************
* \brief This function is just used to generate some example data for write operations
* on the card.
*
**********************************************************************************************/
/***********************************************************************************************
* \brief This function is just used to generate some example data for write operations
* on the card.
*
**********************************************************************************************/
void at24cxx_Start( void )
{
at24cxx_Delay_10us();
at24cxx_IO_input();
AT24CXX_IO_HIGH();
at24cxx_Delay_10us();
AT24CXX_CLK_HIGH();
at24cxx_Delay_10us();
AT24CXX_IO_LOW();
at24cxx_Delay_10us();
AT24CXX_CLK_LOW();
at24cxx_Delay_10us();
}
/***********************************************************************************************
* \brief This function is just used to generate some example data for write operations
* on the card.
*
**********************************************************************************************/
void at24cxx_Stop( void )
{
at24cxx_IO_ouput();
AT24CXX_IO_LOW();
at24cxx_Delay_10us();
AT24CXX_CLK_HIGH();
at24cxx_Delay_10us();
AT24CXX_IO_HIGH();
at24cxx_Delay_10us();
}
/***********************************************************************************************
* \brief This function is just used to generate some example data for write operations
* on the card.
*
**********************************************************************************************/
void at24cxx_SEND_ACK( void )
{
AT24CXX_CLK_LOW();
at24cxx_Delay_5us();
at24cxx_IO_ouput();
AT24CXX_IO_LOW();
at24cxx_Delay_10us();
AT24CXX_CLK_HIGH();
at24cxx_Delay_10us();
AT24CXX_CLK_LOW();
at24cxx_Delay_10us();
}
/***********************************************************************************************
* \brief This function is just used to generate some example data for write operations
* on the card.
*
**********************************************************************************************/
void at24cxx_SEND_NACK( void )
{
AT24CXX_CLK_LOW();
at24cxx_Delay_5us();
at24cxx_IO_ouput();
AT24CXX_IO_HIGH();
at24cxx_Delay_10us();
AT24CXX_CLK_HIGH();
at24cxx_Delay_10us();
AT24CXX_CLK_LOW();
at24cxx_Delay_10us();
}
/***********************************************************************************************
* \brief This function is just used to generate some example data for write operations
* on the card.
*
**********************************************************************************************/
void at24cxx_RECV_ACK( void )
{
AT24CXX_CLK_LOW();
at24cxx_Delay_5us();
at24cxx_IO_input();
at24cxx_Delay_10us();
AT24CXX_CLK_HIGH();
at24cxx_Delay_5us();
iic_retry_times = 200;
iic_ack_flag = 0;
do
{
if( !IIC_SDA_PIN )
{
iic_ack_flag = 1; //sucessful sending
break;
}
at24cxx_Delay_5us();
iic_retry_times--;
}while( iic_retry_times > 0 );
AT24CXX_CLK_LOW();
}
/***********************************************************************************************
* \brief This function is just used to generate some example data for write operations
* on the card.
*
**********************************************************************************************/
void at24cxx_Recv_Char( void )
{
iic_count = 0x08;
at24cxx_IO_input();
at24cxx_Delay_5us();
do
{
iic_recvByte <<= 1;
AT24CXX_CLK_LOW();
at24cxx_Delay_10us();
AT24CXX_CLK_HIGH();
at24cxx_Delay_5us();
if( IIC_SDA_PIN )
{
iic_recvByte |= 0x01;
}
else
{
iic_recvByte &= 0xFE;
}
at24cxx_Delay_5us();
AT24CXX_CLK_LOW();
iic_count--;
}while( iic_count > 0 );
at24cxx_Delay_10us();
}
/***********************************************************************************************
* \brief This function is just used to generate some example data for write operations
* on the card.
*
**********************************************************************************************/
void at24cxx_Send_Char( void )
{
iic_count = 0x08;
at24cxx_IO_ouput();
at24cxx_Delay_5us();
do
{
AT24CXX_CLK_LOW();
at24cxx_Delay_5us();
if( iic_sendByte.7 )
{
AT24CXX_IO_HIGH();
}
else
{
AT24CXX_IO_LOW();
}
iic_sendByte <<= 1;
at24cxx_Delay_5us();
AT24CXX_CLK_HIGH();
at24cxx_Delay_10us();
iic_count--;
}while( iic_count > 0 );
AT24CXX_CLK_LOW();
}
/***********************************************************************************************
* \brief This function is just used to generate some example data for write operations
* on the card.
*
**********************************************************************************************/
void read_Random_Byte( void )
{
iic_rd_successful_flag = 0;
at24cxx_Start();
iic_sendByte = IIC_COMMAND_WRITE;
at24cxx_Send_Char();
at24cxx_RECV_ACK();
if( !iic_ack_flag )
{
iic_rd_successful_flag = 1;
return;
}
iic_sendByte = iic_Address;
at24cxx_Send_Char();
at24cxx_RECV_ACK();
if( !iic_ack_flag )
{
iic_rd_successful_flag = 1;
return;
}
//
at24cxx_Start();
iic_sendByte = IIC_COMMAND_READ;
at24cxx_Send_Char();
at24cxx_RECV_ACK();
if( !iic_ack_flag )
{
iic_rd_successful_flag = 1;
return;
}
//
at24cxx_Recv_Char();
at24cxx_SEND_NACK();
iic_Data = iic_recvByte;
at24cxx_Stop();
}
/***********************************************************************************************
* \brief This function is just used to generate some example data for write operations
* on the card.
*
**********************************************************************************************/
void write_Random_Byte( void )
{
iic_rd_successful_flag = 0;
at24cxx_Start();
iic_sendByte = IIC_COMMAND_WRITE;
at24cxx_Send_Char( );
at24cxx_RECV_ACK();
if( !iic_ack_flag )
{
iic_rd_successful_flag = 1;
return;
}
iic_sendByte = iic_Address;
at24cxx_Send_Char( );
at24cxx_RECV_ACK();
if( !iic_ack_flag )
{
iic_rd_successful_flag = 1;
……………………
…………限于本文篇幅 余下代碼請從51黑下載附件…………
復制代碼
歡迎光臨 (http://www.raoushi.com/bbs/)
Powered by Discuz! X3.1