在线观看www成人影院-在线观看www日本免费网站-在线观看www视频-在线观看操-欧美18在线-欧美1级

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評(píng)論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫(xiě)文章/發(fā)帖/加入社區(qū)
會(huì)員中心
創(chuàng)作中心

完善資料讓更多小伙伴認(rèn)識(shí)你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

如何對(duì)MAX14915/16進(jìn)行編程 - 8通道高邊開(kāi)關(guān)

星星科技指導(dǎo)員 ? 來(lái)源:ADI ? 作者:ADI ? 2023-06-13 16:29 ? 次閱讀

MAX14915為8通道高邊開(kāi)關(guān)。它支持8通道驅(qū)動(dòng)1A。微控制器兼容型串行外設(shè)接口(SPI)提供對(duì)許多診斷功能的訪問(wèn)。本應(yīng)用筆記提供了C代碼實(shí)現(xiàn)示例,包括設(shè)置、監(jiān)控和診斷功能。

介紹

MAX14915/MAX14916集成8個(gè)高邊開(kāi)關(guān),提供輸出通道數(shù)、限流和診斷功能等特性。MAX14915為八通道高邊開(kāi)關(guān),具有豐富的診斷功能和每通道1A (典型值)電流限值。MAX14916可配置為八通道高邊開(kāi)關(guān)(1A限流)或四通道高邊開(kāi)關(guān)(2A限流)。這些器件具有單獨(dú)的通道熱保護(hù)、用于快速感應(yīng)退磁的內(nèi)部箝位以及用于開(kāi)和關(guān)狀態(tài)的開(kāi)路檢測(cè)。此外,還有一個(gè)集成的發(fā)光二極管LED)矩陣,可顯示每個(gè)通道的狀態(tài)(開(kāi)/關(guān))以及故障條件。

本應(yīng)用筆記介紹了一系列功能,為MAX14915/6編程提供簡(jiǎn)單且經(jīng)過(guò)驗(yàn)證的解決方案(圖1)。它們是用C語(yǔ)言編寫(xiě)的,應(yīng)該很容易移植到任何常見(jiàn)的微控制器上。有關(guān)MAX14915引腳、工作模式和控制寄存器的詳細(xì)信息,請(qǐng)參考MAX14915數(shù)據(jù)資料。有關(guān)MAX14916引腳、工作模式和控制寄存器的詳細(xì)信息,請(qǐng)參考MAX14916數(shù)據(jù)資料。

本應(yīng)用筆記主要展示了MAX14915的編程,但MAX14916的技術(shù)非常相似。

wKgaomSIKPyAcPd-AAB03Vv4fQk507.png

圖1.MAX14915功能框圖

MAX14915 SPI

MAX14915 SPI命令長(zhǎng)度為16位(8位指令+8位數(shù)據(jù)),CRC禁用,如果使能CRC,則CRC8將增加8位。命令字節(jié)的 2 MSB 是芯片地址位,它們?cè)试S 4 個(gè)芯片共享相同的芯片選擇 (CS) 引腳。 SPI 命令結(jié)構(gòu)如表 1 所示。MAX14915的SPI模式為CPOL = 0 (CLK空閑= 0),CPHA = 0 (上升沿/第一沿對(duì)數(shù)據(jù)進(jìn)行采樣),數(shù)據(jù)/命令需要先以MSB時(shí)鐘

芯片地址 突發(fā)位 注冊(cè) -
地址
R/W 數(shù)據(jù)
2 位
A[1:0]
1 位
BRST[0]
4 位
R[3:0]
MSB 至 LSB
1 位
RW[0]
8 位
D[7:0]
MSB 至 LSB

有關(guān)SPI讀寫(xiě)周期以及寄存器表和指令的更多詳細(xì)信息,請(qǐng)參考MAX14915和MAX14916數(shù)據(jù)資料。

圖1所示為MAX14915的主要功能塊。基本上,有8個(gè)輸出通道高邊驅(qū)動(dòng)器看門(mén)狗和診斷、一個(gè)16個(gè)LED(4x4)矩陣驅(qū)動(dòng)器和邏輯端接口(SPI端口),用于訪問(wèn)所有器件寄存器和硬件標(biāo)志以進(jìn)行診斷。

MAX14915 – 代碼應(yīng)用示例

MAX14915設(shè)計(jì)用于支持終端設(shè)備的工業(yè)應(yīng)用,如需要多個(gè)高邊開(kāi)關(guān)的可編程邏輯控制器PLC)。支持16通道組隔離的典型應(yīng)用電路采用單個(gè)MAX14483數(shù)字隔離器,如圖2所示。

wKgaomSIKP6AaaLkAAKErTbxQhw676.jpg

圖2.16通道高邊開(kāi)關(guān)組隔離。

每個(gè)單獨(dú)的輸出可以驅(qū)動(dòng)高達(dá) 1A 的電流,并具有單獨(dú)的開(kāi)路、過(guò)流和過(guò)溫診斷

為了簡(jiǎn)化需要電流隔離的系統(tǒng),MAX14915支持菊花鏈和尋址SPI模式。

注意: 某些診斷功能僅在直接 SPI 或?qū)ぶ?SPI 模式下可用,但在菊花鏈模式下不可用。詳情請(qǐng)參考MAX14915數(shù)據(jù)資料。

源代碼

本應(yīng)用筆記提供了C源代碼示例,主要提供驅(qū)動(dòng)器功能,用于訪問(wèn)MAX14915中的多個(gè)寄存器,以實(shí)現(xiàn)配置、控制和診斷功能。所有軟件均使用MAX14915評(píng)估板進(jìn)行實(shí)現(xiàn)和測(cè)試。客戶應(yīng)僅將本文檔中的功能用作參考,并根據(jù)其應(yīng)用程序中的微控制器和硬件實(shí)現(xiàn)設(shè)計(jì)自己的固件/軟件。

寄存器地址定義:

#define REG_SetOUT       0x00
#define REG_SetFLED      0x01
#define REG_SetSLED      0x02
#define REG_Interupt     0x03
#define REG_OvlChF       0x04
#define REG_CurrLimF     0x05
#define REG_OwOffChF     0x06
#define REG_OwOnChF      0x07
#define REG_ShtVDDChF    0x08
#define REG_GlobalErr    0x09
#define REG_OwOffEn      0x0a
#define REG_OwOnEn       0x0b
#define REG_ShtVddEn     0x0c
#define REG_Config1      0x0d
#define REG_Config2      0x0e
#define REG_Mask         0x0f

其他定義:

#define OUT1             0x01
#define OUT2             0x02
#define OUT3             0x04
#define OUT4             0x08
#define OUT5             0x10
#define OUT6             0x20
#define OUT7             0x40
#define OUT8             0x80

#define GLB_ShrtVDD      0x20
#define GLB_OWOnF        0x10
#define GLB_OWOffF       0x08
#define GLB_CurrLim      0x04
#define GLB_OverLdF      0x02
#define GLB_GloblF       0x01

bool CRC_Enabled = true;             // if pin CRCEN = high, then this must be true
//bool CRC_Enabled = false;            // if pin CRCEN = low, then this must be false
const int CRC_ERROR = 0xffff;

該測(cè)試程序等待MAX14915,直到它沒(méi)有報(bào)告任何故障,例如在上電MAX14915報(bào)告上電復(fù)位條件之后。接下來(lái),對(duì)MAX14915進(jìn)行初始化,以便報(bào)告任何故障,作為典型上電自檢程序的一部分,二進(jìn)制計(jì)數(shù)器在8個(gè)通道上運(yùn)行并打印故障條件。

void test()
{
  uint8_t ADR = 0;                   // MAX14915 Chip-Address Allows multiple Chips with 1 Chip-Select
  uint16_t loop_count = 0;

  // Check status, only continue if All OK.
  uint16_t fault = 0xffff;
  while (fault != 0)                 // Halt until MAX14915 has no faults
  {
	  fault = MAX14915_Init(ADR);
	  if ( (fault) != 0) MAX14915_Identify_Error(ADR, fault);  // check for errors if any bit is set
  }

  // Writes a binary counter to the 8 Ports
  // Checks for any errors and prints them
  while (1)
  {
	  printf("Writing %i\r\n", loop_count);

	  uint16_t w_result = MAX14915_write_register(ADR, REG_SetOUT, loop_count);
	  w_result = w_result & 0x3fff;                                     // ignore the 2 MSBs, they're not used

	  printf("W-Result 0x%04x\r\n", w_result);
	  if ( (w_result) != 0) MAX14915_Identify_Error(ADR, w_result);     // only check if any bit is set

	  delay_ms(100);
	  loop_count++;
	  if (loop_count > 255) loop_count = 0;
  }
}

這些是初始化和使用MAX14915所需的功能,包括寄存器讀寫(xiě)操作、CRC代碼生成和解碼以及錯(cuò)誤標(biāo)志輪詢。

//********************************************************************
//*
//* Function: MAX14915_Init
//* Description: Initialize MAX14915
//*
//* Input:
//*         Chip_Address:     Chip address selected by pins A1 and A0
//*
//* Output, none
//*         Initializes the device after power-up
//*
//* if CRC is enabled, then crc5 is sent accordingly
//*
//********************************************************************/
uint16_t MAX14915_Init(uint8_t Chip_Address)
{
	// **********************************************************************************
	// *   D07   *   D06   *   D05   *   D04   **   D03   *   D02   *   D01   *   D00   *
	// * ComErrM *SuplErrM *  VddOKM * ShtVddM **  OWOnM  *  OWOffM * OWOffM  * OverLdM *
	// *    1    *    0    *    0    *    0    **    0    *    0    *    0    *    0    *
	// **********************************************************************************
	// -> 0x80   // All warnings enabled, just Watchdog off
	uint16_t result = MAX14915_write_register(Chip_Address, REG_Mask, 0x80);

	// **********************************************************************************
	// *   D07   *   D06   *   D05   *   D04   **   D03   *   D02   *   D01   *   D00   *
	// * LEDCLim * FLatchEn*FiltrLong*FFilterEn**FLEDStr1 *FLEDStr0 * SLEDSet * FLEDSet *
	// *    0    *    1    *    0    *    1    **    0    *    0    *    0    *    0    *
	// **********************************************************************************
	// -> 0x50   // Enable Status and Fault LEDs
	             // Keep Fault-Latch and Filter-Blanking on
	result |= MAX14915_write_register(Chip_Address, REG_Config1, 0x50);

	// enable Open-Wire when off detection on all Channels
	// this only works if a load is connected on all channels
	// Maybe should be handled by the Application?
	result |= MAX14915_write_register(Chip_Address, REG_OwOffEn, 0xff);

	// enable Open-Wire when on detection on all Channels
	// this only works if a load is connected on all channels
	// Maybe should be handled by the Application?
	result |= MAX14915_write_register(Chip_Address, REG_OwOnEn, 0xff);

	// enable Short to VDD detection on all Channels
	// this only works if a load is connected on all channels
	// Maybe should be handled by the Application?
	result |= MAX14915_write_register(Chip_Address, REG_ShtVddEn, 0xff);


	return result & 0x3fff; // discard the 2 MSBs, since they're unused
}
 
//********************************************************************
//*
//* Function: MAX14915_write_register
//* Description: Write one Register to MAX14915
//*
//* Input:
//*         Chip_Address:     Chip address selected by pins A1 and A0
//*         Register-Address  take from definitions in header-file
//*         data              Data to be written into the register
//*
//* Output, 16bit result:
//*         MSB 8-bits = Global Error uint8_t
//*         LSB 8-bits = Fault bits F8 to F1
//*
//* if CRC is enabled, then crc5 is sent accordingly
//*
//********************************************************************/
uint16_t MAX14915_write_register(uint8_t Chip_Address, uint8_t Register_Address, uint8_t data)
{
    // Construct the SPI uint8_t to transmit
    uint8_t  CHIP_ADR = (uint8_t) (Chip_Address<<6);       // 2 MSBs are the Chip Address (A1 and A0)
    uint8_t  BRST     = 0;                              // 0 = no burst read; 1 = burst read  -> 0x20 to set this bit
    uint8_t  R_ADR    = (uint8_t) (Register_Address<<1);   // Register Address

    uint8_t  command  = (uint8_t) (CHIP_ADR | BRST | R_ADR | 1); // construct SPI Command uint8_t. LSB = 1 for Write-Command
    // END Construct the SPI uint8_t to transmit

    MAX14915_CS_Low();
    // Write Command-uint8_t, Receive the Global Error uint8_t at the same time
    uint8_t GLOB_ERROR = MAX14915_SPI_RW_8bit(command);
    // Write Data-uint8_t, Receive the Individual Fault-Bits at the same time
    uint8_t FAULT_BITS = MAX14915_SPI_RW_8bit(data);

    if (CRC_Enabled == true)
    {
        uint8_t crc5_checksum;
        crc5_checksum = MAX14915_crc5_encode_2byte(command, data);
        MAX14915_SPI_RW_8bit(crc5_checksum);
    }
    MAX14915_CS_High();

    return (uint16_t) ((GLOB_ERROR << 8) | FAULT_BITS);;
}

 
//********************************************************************
//*
//* Function: MAX14915_read_register
//* Description: Read one Register from MAX14915
//*
//* Input:
//*         Chip_Address:     Chip address selected by pins A1 and A0
//*         Register-Address  take from definitions in header-file
//*         data              Data to be written into the register
//*
//*
//* Output, 16bit result:
//*         MSB 8-bits = Global Error uint8_t
//*         LSB 8-bits = Register content 8-bits
//*
//* if CRC is enabled and there was a CRC error, then Output is CRC_ERROR
//*
//********************************************************************/
uint16_t MAX14915_read_register (uint8_t Chip_Address, uint8_t Register_Address)
{
    // Construct the SPI uint8_t to transmit
    uint8_t  CHIP_ADR = (uint8_t) (Chip_Address<<6);       // 2 MSBs are the Chip Address (A1 and A0)
    uint8_t  BRST     = 0;                                 // 0 = no burst read; 1 = burst read  -> 0x20 to set this bit
    uint8_t  R_ADR    = (uint8_t) (Register_Address<<1);   // Register Address

    uint8_t  command  = (uint8_t) (CHIP_ADR | BRST | R_ADR); // construct SPI Command uint8_t. LSB = 0 for Read-Command
    // END Construct the SPI uint8_t to transmit

    MAX14915_CS_Low();
    // Write Command-uint8_t, Receive the Global Error uint8_t at the same time
    uint8_t GLOB_ERROR = MAX14915_SPI_RW_8bit(command);
    GLOB_ERROR = GLOB_ERROR & 0x3f;                      // Discard the 2 MSBs, they're not used

    // Write Data-uint8_t, Receive the Individual Fault-Bits at the same time
    uint8_t data       = MAX14915_SPI_RW_8bit(0);

    if (CRC_Enabled == true)
    {
        uint8_t crc5_read;
        uint8_t crc5_calc;

        crc5_calc = MAX14915_crc5_decode_2byte(GLOB_ERROR, data);
    	crc5_read = MAX14915_SPI_RW_8bit(MAX14915_crc5_encode_2byte(command,0));

    	if (crc5_read != crc5_calc) System_Handle_CRC_Error(Chip_Address);
    }
    MAX14915_CS_High();

    return (uint16_t) ((GLOB_ERROR << 8) | data);
}
 
//********************************************************************
//*
//* Function: MAX14915_crc5encode_2byte
//* Description: Generates CRC5 byte for 2 byte-Command
//*                        this is needed for WRITE commands
//*
//* Input:
//*         byte1:     Usually Command Byte
//*         byte2:     Byte written to MAX14915
//*
//* Output, 8bit result:
//*         CRC5 of the 2 Bytes
//*
//********************************************************************/
uint8_t MAX14915_crc5_encode_2byte(uint8_t byte1, uint8_t byte2)
{
    uint8_t crc5_start = 0x1f;
    uint8_t crc5_poly  = 0x15;
    uint8_t crc_result = crc5_start;

    // byte1
    for (int i=0; i<8; i++)
    {
        if( ((( byte1>>(7-i) )&0x01) ^ ((crc_result & 0x10)>>4)) > 0  )
        {
            crc_result = (uint8_t) (crc5_poly ^ ((crc_result<<1) & 0x1f));
        }
        else
        {
            crc_result = (uint8_t)((crc_result<<1) & 0x1f);
        }
    }
    // END byte1

    // byte2
    for (int i=0; i<8; i++)
    {
        if( ((( byte2>>(7-i) )&0x01) ^ ((crc_result & 0x10)>>4)) > 0  )
        {
            crc_result = (uint8_t) (crc5_poly ^ ((crc_result<<1) & 0x1f));
        }
        else
        {
            crc_result = (uint8_t)((crc_result<<1) & 0x1f);
        }
    }
    // END byte2

    // 3 extra bits set to zero
    uint8_t uint8_t3=0x00;
    for (int i=0; i<3; i++)
    {
        if( ((( uint8_t3>>(7-i) )&0x01) ^ ((crc_result & 0x10)>>4)) > 0  )
        {
            crc_result = (uint8_t) (crc5_poly ^ ((crc_result<<1) & 0x1f));
        }
        else
        {
            crc_result = (uint8_t)((crc_result<<1) & 0x1f);
        }
    }
    // END 3 extra bits set to zero

    return crc_result;
}
 
//********************************************************************
//*
//* Function: MAX14915_crc5_decode_2byte
//* Description: Decodes   CRC5 byte for 2 byte-Command
//*                        this is needed for READ commands
//*
//* Input:
//*         byte1:     Usually Command Byte
//*         byte2:     byte read from MAX14915
//*
//* Output, 8bit result:
//*         CRC5 of the 2 Bytes
//*
//********************************************************************/
uint8_t MAX14915_crc5_decode_2byte(uint8_t byte1, uint8_t byte2)
{
	uint8_t crc5_start = 0x1f;
	uint8_t crc5_poly  = 0x15;
	uint8_t crc_result = crc5_start;

    // BYTE1
    for (int i=2; i<8; i++)
    {
        if( ((( byte1>>(7-i) )&0x01) ^ ((crc_result & 0x10)>>4)) > 0  )  // IF(XOR(C6;BITAND(D5;2^4)/2^4)
        {  // BITXOR($D$1;BITAND((D5*2);31))
            crc_result = (uint8_t) (crc5_poly ^ ((crc_result<<1) & 0x1f));
        }
        else
        {
            crc_result = (uint8_t)((crc_result<<1) & 0x1f);
        }
    }
    // END BYTE1

    // BYTE2
    for (int i=0; i<8; i++)
    {
        if( ((( byte2>>(7-i) )&0x01) ^ ((crc_result & 0x10)>>4)) > 0  )  // IF(XOR(C6;BITAND(D5;2^4)/2^4)
        {  // BITXOR($D$1;BITAND((D5*2);31))
            crc_result = (uint8_t) (crc5_poly ^ ((crc_result<<1) & 0x1f));
        }
        else
        {
            crc_result = (uint8_t)((crc_result<<1) & 0x1f);
        }
    }
    // END BYTE2

    // 3 extra bits set to zero
    uint8_t byte3=0x00;
    for (int i=0; i<3; i++)
    {
        if( ((( byte3>>(7-i) )&0x01) ^ ((crc_result & 0x10)>>4)) > 0  )  // IF(XOR(C6;BITAND(D5;2^4)/2^4)
        {  // BITXOR($D$1;BITAND((D5*2);31))
            crc_result = (uint8_t) (crc5_poly ^ ((crc_result<<1) & 0x1f));
        }
        else
        {
            crc_result = (uint8_t)((crc_result<<1) & 0x1f);
        }
    }
    // END 3 extra bits set to zero

    return crc_result;
}

 
//********************************************************************
//*
//* Function: MAX14915_Identify_Error
//* Description: This should be called if one of the Global-Error bits
//*              or Fault bits is set
//*              This function identifies the error and calls
//*
//* Input:
//*         uint16_t:    MS-uint8_t = Global Errors from SPI transfer
//*                    LS-uint8_t = Channel Fault bits from SPI transfer
//*
//* Output:
//*         none, will call System Level function to handle the error
//*
//********************************************************************/
void MAX14915_Identify_Error(uint8_t Chip_Address, uint16_t ERROR_INFO)
{
    uint8_t   GlobalERR  = (uint8_t) ((ERROR_INFO>>8) & 0xff); // MSB 8-bits = Global Error uint8_t
    uint8_t   CH_FAULT   = (uint8_t) ((ERROR_INFO)    & 0xff); // LSB 8-bits = Fault bits F8 to F1

    if ((GlobalERR & GLB_GloblF)  != 0)   System_Handle_Global_fault(Chip_Address);

    // If no Channel Fault, then no further checking is needed:
    if (CH_FAULT == 0) return;

    // if only one single fault exists, then Error-Type is already known by Global_Error_uint8_t
    if ( (CH_FAULT == OUT1) ||
         (CH_FAULT == OUT2) ||
         (CH_FAULT == OUT3) ||
         (CH_FAULT == OUT4) ||
         (CH_FAULT == OUT5) ||
         (CH_FAULT == OUT6) ||
         (CH_FAULT == OUT7) ||
         (CH_FAULT == OUT8) )
    {
    	uint8_t ch_number = MAX14915_decode_channel_number(CH_FAULT);
        if ((GlobalERR & GLB_ShrtVDD) != 0)   System_Handle_Short_to_VDD_CH(ch_number, Chip_Address);
        if ((GlobalERR & GLB_OWOnF)   != 0)   System_Handle_OpenWire_CH(ch_number, Chip_Address);
        if ((GlobalERR & GLB_OWOffF)  != 0)   System_Handle_OpenWire_CH(ch_number, Chip_Address);
        if ((GlobalERR & GLB_CurrLim) != 0)   System_Handle_Current_Limit_CH(ch_number, Chip_Address);
        if ((GlobalERR & GLB_OverLdF) != 0)   System_Handle_Overload_CH(ch_number, Chip_Address);
    }
    else
    {   // there is more than 1 error present
        // so we need to check each channel

        // first read each Error Register:
        uint16_t OvlChF    = MAX14915_read_register (Chip_Address, REG_OvlChF);
        uint16_t CurrLim   = MAX14915_read_register (Chip_Address, REG_CurrLimF);
        uint16_t OwOffChF  = MAX14915_read_register (Chip_Address, REG_OwOffChF);
        uint16_t OwOnChF   = MAX14915_read_register (Chip_Address, REG_OwOnChF);
        uint16_t ShtVDDChF = MAX14915_read_register (Chip_Address, REG_ShtVDDChF);

        if ((OvlChF    & OUT1) != 0) System_Handle_Overload_CH(1, Chip_Address);
        if ((OvlChF    & OUT2) != 0) System_Handle_Overload_CH(2, Chip_Address);
        if ((OvlChF    & OUT3) != 0) System_Handle_Overload_CH(3, Chip_Address);
        if ((OvlChF    & OUT4) != 0) System_Handle_Overload_CH(4, Chip_Address);
        if ((OvlChF    & OUT5) != 0) System_Handle_Overload_CH(5, Chip_Address);
        if ((OvlChF    & OUT6) != 0) System_Handle_Overload_CH(6, Chip_Address);
        if ((OvlChF    & OUT7) != 0) System_Handle_Overload_CH(7, Chip_Address);
        if ((OvlChF    & OUT8) != 0) System_Handle_Overload_CH(8, Chip_Address);

        if ((CurrLim   & OUT1) != 0) System_Handle_Current_Limit_CH(1, Chip_Address);
        if ((CurrLim   & OUT2) != 0) System_Handle_Current_Limit_CH(2, Chip_Address);
        if ((CurrLim   & OUT3) != 0) System_Handle_Current_Limit_CH(3, Chip_Address);
        if ((CurrLim   & OUT4) != 0) System_Handle_Current_Limit_CH(4, Chip_Address);
        if ((CurrLim   & OUT5) != 0) System_Handle_Current_Limit_CH(5, Chip_Address);
        if ((CurrLim   & OUT6) != 0) System_Handle_Current_Limit_CH(6, Chip_Address);
        if ((CurrLim   & OUT7) != 0) System_Handle_Current_Limit_CH(7, Chip_Address);
        if ((CurrLim   & OUT8) != 0) System_Handle_Current_Limit_CH(8, Chip_Address);

        if ((OwOffChF  & OUT1) != 0) System_Handle_OpenWire_CH(1, Chip_Address);
        if ((OwOffChF  & OUT2) != 0) System_Handle_OpenWire_CH(2, Chip_Address);
        if ((OwOffChF  & OUT3) != 0) System_Handle_OpenWire_CH(3, Chip_Address);
        if ((OwOffChF  & OUT4) != 0) System_Handle_OpenWire_CH(4, Chip_Address);
        if ((OwOffChF  & OUT5) != 0) System_Handle_OpenWire_CH(5, Chip_Address);
        if ((OwOffChF  & OUT6) != 0) System_Handle_OpenWire_CH(6, Chip_Address);
        if ((OwOffChF  & OUT7) != 0) System_Handle_OpenWire_CH(7, Chip_Address);
        if ((OwOffChF  & OUT8) != 0) System_Handle_OpenWire_CH(8, Chip_Address);

        if ((OwOnChF   & OUT1) != 0) System_Handle_OpenWire_CH(1, Chip_Address);
        if ((OwOnChF   & OUT2) != 0) System_Handle_OpenWire_CH(2, Chip_Address);
        if ((OwOnChF   & OUT3) != 0) System_Handle_OpenWire_CH(3, Chip_Address);
        if ((OwOnChF   & OUT4) != 0) System_Handle_OpenWire_CH(4, Chip_Address);
        if ((OwOnChF   & OUT5) != 0) System_Handle_OpenWire_CH(5, Chip_Address);
        if ((OwOnChF   & OUT6) != 0) System_Handle_OpenWire_CH(6, Chip_Address);
        if ((OwOnChF   & OUT7) != 0) System_Handle_OpenWire_CH(7, Chip_Address);
        if ((OwOnChF   & OUT8) != 0) System_Handle_OpenWire_CH(8, Chip_Address);

        if ((ShtVDDChF & OUT1) != 0) System_Handle_Short_to_VDD_CH(1, Chip_Address);
        if ((ShtVDDChF & OUT2) != 0) System_Handle_Short_to_VDD_CH(2, Chip_Address);
        if ((ShtVDDChF & OUT3) != 0) System_Handle_Short_to_VDD_CH(3, Chip_Address);
        if ((ShtVDDChF & OUT4) != 0) System_Handle_Short_to_VDD_CH(4, Chip_Address);
        if ((ShtVDDChF & OUT5) != 0) System_Handle_Short_to_VDD_CH(5, Chip_Address);
        if ((ShtVDDChF & OUT6) != 0) System_Handle_Short_to_VDD_CH(6, Chip_Address);
        if ((ShtVDDChF & OUT7) != 0) System_Handle_Short_to_VDD_CH(7, Chip_Address);
        if ((ShtVDDChF & OUT8) != 0) System_Handle_Short_to_VDD_CH(8, Chip_Address);
    }
}

uint8_t MAX14915_decode_channel_number(uint8_t CH_binary)
{
    if ((CH_binary & OUT1) != 0) return 1;
    if ((CH_binary & OUT2) != 0) return 2;
    if ((CH_binary & OUT3) != 0) return 3;
    if ((CH_binary & OUT4) != 0) return 4;
    if ((CH_binary & OUT5) != 0) return 5;
    if ((CH_binary & OUT6) != 0) return 6;
    if ((CH_binary & OUT7) != 0) return 7;
    if ((CH_binary & OUT8) != 0) return 8;

    return 0;
}

這些功能顯示了MAX14915的診斷特性。在此示例中,僅打印錯(cuò)誤條件。真正的應(yīng)用程序可能必須采取進(jìn)一步的操作:

void System_Handle_Overload_CH(uint8_t Channel, uint8_t Chip_Address)
{
    // "Channel" is overloaded
    // System needs to handle over-load on "Channel"
    // Print to the User?
    // Just switch off?
    printf("MAX14915 %i - Channel %i is overloaded\r\n", Chip_Address, Channel);

    // Application actions

    MAX14915_read_register (Chip_Address, REG_OvlChF);  // read to clear the flag
                                                        // if error persists, the flag
                                                        // will come back immediately
}

void System_Handle_Current_Limit_CH(uint8_t Channel, uint8_t Chip_Address)
{
    // "Channel" is in current limiting mode
    // Does the system have to do anything in this case?
    // Print to the User?
    // Just switch off?
    printf("MAX14915 %i - Channel %i is in Current Limiting mode\r\n", Chip_Address, Channel);

    // Application actions

    MAX14915_read_register (Chip_Address, REG_CurrLimF); // read to clear the flag
                                                         // if error persists, the flag
                                                         // will come back immediately
}

void System_Handle_OpenWire_CH(uint8_t Channel, uint8_t Chip_Address)
{
    // "Channel" is open wire
    // Does the system have to do anything in this case?
    // Print to the User?
    printf("MAX14915 %i - Channel %i is Open Wire\r\n", Chip_Address, Channel);

    // Application actions

    MAX14915_read_register (Chip_Address, REG_OwOnChF);
    MAX14915_read_register (Chip_Address, REG_OwOffChF); // read to clear the flag
                                                         // if error persists, the flag
                                                         // will come back immediately
}

void System_Handle_Short_to_VDD_CH(uint8_t Channel, uint8_t Chip_Address)
{
    // "Channel" is shorted to VDD
    // Does the system have to do anything in this case?
    // Print to the User?
    // Just switch off?
    printf("MAX14915 %i - Channel %i is shorted to VDD\r\n", Chip_Address, Channel);

    // Application actions

    MAX14915_read_register (Chip_Address, REG_ShtVDDChF); // read to clear the flag
                                                          // if error persists, the flag
                                                          // will come back immediately
}

void System_Handle_Global_fault(uint8_t Chip_Address)
{
	// read Global Error Register
    uint16_t global_error = MAX14915_read_register (Chip_Address, REG_GlobalErr);

    if ((global_error & 0x02) != 0) printf("MAX14915 %i Logic Undervoltage\r\n", Chip_Address);
    if ((global_error & 0x04) != 0) printf("MAX14915 %i VDD not good (below 16V)\r\n", Chip_Address);
    if ((global_error & 0x08) != 0) printf("MAX14915 %i VDD warning (below 13V)\r\n", Chip_Address);
    if ((global_error & 0x10) != 0) printf("MAX14915 %i VDD Undervoltage (below 8V)\r\n", Chip_Address);
    if ((global_error & 0x20) != 0) printf("MAX14915 %i Thermal Shutdown\r\n", Chip_Address);
    if ((global_error & 0x40) != 0) printf("MAX14915 %i SYNCH Error\r\n", Chip_Address);
    if ((global_error & 0x80) != 0) printf("MAX14915 %i Watchdog Error\r\n", Chip_Address);

    if ((global_error & 0x01) != 0)
	{
    	// After a power-on reset all registers are in reset state
    	// -> we need to re-initialize to our settings
    	MAX14915_Init(Chip_Address);
    	printf("MAX14915 %i Power-up Reset detected\r\n", Chip_Address);
	}
}


void System_Handle_CRC_Error(uint8_t Chip_Address)
{
    // There was a CRC error
    printf("MAX14915 %i - CRC Error!\r\n", Chip_Address);

    // The Application needs to react here

    MAX14915_read_register (Chip_Address, REG_GlobalErr); // read to clear the flag
                                                          // if error persists, the flag
                                                          // will come back immediately
}

結(jié)論

本應(yīng)用筆記介紹了如何對(duì)MAX14915進(jìn)行編程以驅(qū)動(dòng)輸出和診斷故障條件。該代碼使用MAX14915EVKIT進(jìn)行測(cè)試。工程師可以使用本應(yīng)用筆記中提到的C代碼示例,快速輕松地實(shí)現(xiàn)常用微控制器和MAX14915之間的接口。

審核編輯:郭婷

聲明:本文內(nèi)容及配圖由入駐作者撰寫(xiě)或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點(diǎn)僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場(chǎng)。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問(wèn)題,請(qǐng)聯(lián)系本站處理。 舉報(bào)投訴
  • 微控制器
    +關(guān)注

    關(guān)注

    48

    文章

    7552

    瀏覽量

    151423
  • led
    led
    +關(guān)注

    關(guān)注

    242

    文章

    23277

    瀏覽量

    660873
  • SPI
    SPI
    +關(guān)注

    關(guān)注

    17

    文章

    1706

    瀏覽量

    91582
收藏 人收藏

    評(píng)論

    相關(guān)推薦

    16通道高壓模擬開(kāi)關(guān)MAX14803A相關(guān)資料分享

    16通道高壓模擬開(kāi)關(guān)MAX14803A資料下載內(nèi)容主要介紹了:MAX14803A功能和特點(diǎn)MAX
    發(fā)表于 03-23 06:24

    16通道高壓模擬開(kāi)關(guān)MAX14806相關(guān)資料分享

    16通道高壓模擬開(kāi)關(guān)MAX14806資料下載內(nèi)容主要介紹了:MAX14806功能和特點(diǎn)MAX14
    發(fā)表于 03-23 07:53

    16通道高壓模擬開(kāi)關(guān)MAX14805資料推薦

    16通道高壓模擬開(kāi)關(guān)MAX14805資料下載內(nèi)容包括:MAX14805功能和特點(diǎn)MAX14805
    發(fā)表于 03-23 06:35

    16通道高壓模擬開(kāi)關(guān)MAX14803相關(guān)資料下載

    16通道高壓模擬開(kāi)關(guān)MAX14803資料下載內(nèi)容包括:MAX14803功能和特點(diǎn)MAX14803
    發(fā)表于 03-26 06:01

    16通道高壓模擬開(kāi)關(guān)MAX14802資料推薦

    16通道高壓模擬開(kāi)關(guān)MAX14802資料下載內(nèi)容包括:MAX14802功能和特點(diǎn)MAX14802
    發(fā)表于 03-31 06:43

    16通道高壓模擬開(kāi)關(guān)MAX14800電子資料

    概述:MAX14800采用48引腳TQFP封裝,所有器件都工作于0°C至+70°C商業(yè)級(jí)溫度范圍。可為超聲成像和打印機(jī)應(yīng)用提供16通道高壓開(kāi)關(guān)。該系列器件采用HVCMOS工藝,提供
    發(fā)表于 04-14 06:25

    MAX306, MAX307 高精度、16通道/雙8通道

    MAX306, MAX307 高精度、16通道/雙8通道、高性能、CMOS模擬多路復(fù)用器 &
    發(fā)表于 03-20 08:31 ?4034次閱讀
    <b class='flag-5'>MAX</b>306, <b class='flag-5'>MAX</b>307 高精度、<b class='flag-5'>16</b><b class='flag-5'>通道</b>/雙<b class='flag-5'>8</b><b class='flag-5'>通道</b>、<b class='flag-5'>高</b>

    MAX16070, MAX16071 12通道/8通道、閃存

    MAX16070, MAX16071 12通道/8通道、閃存配置系統(tǒng)監(jiān)測(cè)器,提供非易失故障寄存器 MA
    發(fā)表于 04-05 06:00 ?1037次閱讀

    MAX11044,MAX11045,MAX11046 4/6/8通道16位同時(shí)采樣ADC

    MAX11044, MAX11045, MAX11046 4/6/8通道16位、同時(shí)采樣ADC
    發(fā)表于 04-10 21:10 ?1591次閱讀
    <b class='flag-5'>MAX</b>11044,<b class='flag-5'>MAX</b>11045,<b class='flag-5'>MAX</b>11046 4/6/<b class='flag-5'>8</b><b class='flag-5'>通道</b><b class='flag-5'>16</b>位同時(shí)采樣ADC

    MAX4968,MAX4968A 16通道線性高壓模擬開(kāi)關(guān)

    MAX4968/MAX4968A是16通道線性度,電壓,雙向SPST
    發(fā)表于 07-03 09:14 ?3242次閱讀
    <b class='flag-5'>MAX</b>4968,<b class='flag-5'>MAX</b>4968A <b class='flag-5'>16</b><b class='flag-5'>通道</b><b class='flag-5'>高</b>線性高壓模擬<b class='flag-5'>開(kāi)關(guān)</b>

    8通道電子開(kāi)關(guān)電路

    8通道電子開(kāi)關(guān)電路,都是值得參考的設(shè)計(jì)。
    發(fā)表于 05-11 17:00 ?0次下載

    Maxim八通道開(kāi)關(guān)/驅(qū)動(dòng)器可大幅提升工業(yè)4.0應(yīng)用體驗(yàn)

    Maxim八通道開(kāi)關(guān)/驅(qū)動(dòng)器可對(duì)任意感性負(fù)載安全消磁,大幅提升工業(yè)4.0應(yīng)用體驗(yàn) 。 Maxim針對(duì)工業(yè)4.0應(yīng)用聯(lián)合硅天下科技推出MAX
    發(fā)表于 07-11 10:18 ?934次閱讀

    如何編程 MAX14915/MAX14916 - 8 通道開(kāi)關(guān)

    發(fā)表于 11-16 21:44 ?2次下載
    如何<b class='flag-5'>編程</b> <b class='flag-5'>MAX14915</b>/<b class='flag-5'>MAX</b>14916 - <b class='flag-5'>8</b> <b class='flag-5'>通道</b><b class='flag-5'>高</b><b class='flag-5'>邊</b><b class='flag-5'>開(kāi)關(guān)</b>

    如何對(duì)MAX14915/16進(jìn)行編程 - 8通道開(kāi)關(guān)

    MAX149158通道開(kāi)關(guān)。它支持8
    的頭像 發(fā)表于 02-21 09:44 ?1835次閱讀
    如何對(duì)<b class='flag-5'>MAX14915</b>/<b class='flag-5'>16</b><b class='flag-5'>進(jìn)行</b><b class='flag-5'>編程</b> - <b class='flag-5'>8</b><b class='flag-5'>通道</b><b class='flag-5'>高</b><b class='flag-5'>邊</b><b class='flag-5'>開(kāi)關(guān)</b>

    MAX14915通道、工業(yè)、開(kāi)關(guān)CRC編程指南

    MAX14915為高性能、8通道、工業(yè)開(kāi)關(guān),具有豐富、先進(jìn)的功能集。SPI接口允許微控制器監(jiān)
    的頭像 發(fā)表于 02-21 16:14 ?1248次閱讀
    <b class='flag-5'>MAX14915</b>八<b class='flag-5'>通道</b>、工業(yè)、<b class='flag-5'>高</b><b class='flag-5'>邊</b><b class='flag-5'>開(kāi)關(guān)</b>CRC<b class='flag-5'>編程</b>指南
    主站蜘蛛池模板: 国产精品单位女同事在线| 亚色中文字幕| 天天操天天爽天天射| 噜噜噜色噜噜噜久久| 韩国三级日本三级在线观看| 国产二区三区| 狠狠干狠狠搞| 一级毛片成人免费看a| 教官的好爽好深h片段| 免费观看美女被cao视频| xxxx欧美xxxx黑人| 四虎国产精品永久在线| 97综合久久| 男人日女人免费视频| 久久久国产精品免费看| 你懂的亚洲| a级毛片免费观看网站| 日本69xxxxxxx69| 色丁香六月| 午夜国产高清精品一区免费| good韩国理论在线三级| 婷婷色站| 偷窥自拍亚洲色图| 黄视频网站观看| 狠狠的日视频| 性欧美黑人| 日本在线www| 国产精品四虎| 国产黄色在线视频| 欧美3d动漫网站| 国产福利午夜| 永久毛片| 久久99综合| 欧美黄色免费看| 亚洲色图25p| 一级毛片免费不卡直观看| 夜夜狠狠| 韩国三级视频| 色婷婷九月| 亚洲综合一| ww.色|