• 大小: 15KB
    文件类型: .c
    金币: 1
    下载: 0 次
    发布日期: 2021-06-15
  • 语言: C/C++
  • 标签: ade7758  c语言  

资源简介

ADE7758三相电能芯片读写源程序,全部采用C语言编写

资源截图

代码片段和文件信息

#define 	MANIP7758_GLOBALS
#include “includes.h“

const uchar GACHC_58addr_num[]={1222222222333333
 2131111133322111
 1112222222222222
 2222222222222221
 111112222
};

/****************************************************************/
/*                          Read a byte from 7758                                                 */
/*description: get byte for 7758 output                                                       */
/*                            */
/*                                                                                                            */
/*input parameters:  none                                      */
/*                                                                                                       */
/*output argument:    return the obtaned byte which type is uchar*/
/*relative globe variables or functons:  none                                                              */
/***************************************************************/

uchar read_1byte7758(void)
{
union UN_DEF LUB_data;
uchar i;
LUB_data.BYTE=0;nop();
for(i=0;i!=8;i++)
{
P_7758CLK_HIGH;
//us_delay(1);
us_delay(2);
P_7758CLK_LOW;
LUB_data.BIT.b0=P_7758DOUT;
if(i==7)
{
LUB_data.BYTE=~LUB_data.BYTE;/*invert the obtain bit*/
return LUB_data.BYTE;
}
LUB_data.BYTE<<=1;
//us_delay(1);
us_delay(2);
}
}

/****************************************************************/
/*                              write a byte to 7758                                                  */
/*description:    this  function write one byte to the 7758                               */
/*                            */
/*                                                                                                            */
/*input parameters:  PB_data:the data ready to be write                               */
/*                                                                                                       */
/*output argument: none                                                                        */
/*relative globe variables or functons:none                                                  */
/***************************************************************/
void write_1byte7758(uchar PB_data)
{
uchar i;
union UN_DEF LUB_data;
LUB_data.BYTE=~PB_data;/*invert the certain bit before output*/
for(i=0;i!=8;i++)
{
P_7758DIN=LUB_data.BIT.b7;
P_7758CLK_HIGH;
LUB_data.BYTE<<=1;
//us_delay(1);
us_delay(2);
P_7758CLK_LOW;
//us_delay(1);
us_delay(2);
nop();
}
}
/****************************************************************/
/*                              write a command  to 7758                                                  */
/*description:    this fuction  send a certain   command to the 7758     

评论

共有 条评论