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

0
  • 聊天消息
  • 系統消息
  • 評論與回復
登錄后你可以
  • 下載海量資料
  • 學習在線課程
  • 觀看技術視頻
  • 寫文章/發帖/加入社區
會員中心
創作中心

完善資料讓更多小伙伴認識你,還能領取20積分哦,立即完善>

3天內不再提示

如何對MAX14915/16進行編程 - 8通道高邊開關

星星科技指導員 ? 來源:ADI ? 作者:ADI ? 2023-02-21 09:44 ? 次閱讀

MAX14915為8通道高邊開關。它支持8通道驅動1A。微控制器兼容型串行外設接口(SPI)提供對許多診斷功能的訪問。本應用筆記提供了C代碼實現示例,包括設置、監控和診斷功能。

介紹

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

本應用筆記介紹了一系列功能,為MAX14915/6編程提供簡單且經過驗證的解決方案(圖1)。它們是用C語言編寫的,應該很容易移植到任何常見的微控制器上。

本應用筆記主要展示了MAX14915的編程,但MAX14916的技術非常相似。

poYBAGP0IfeAHgeNAABtIiRnPM8244.png?imgver=1

圖1.MAX14915功能框圖

MAX14915 SPI

MAX14915 SPI命令長度為16位(8位指令+8位數據),CRC禁用,如果使能CRC,則CRC8將增加8位。命令字節的 2 MSB 是芯片地址位,它們允許 4 個芯片共享相同的芯片選擇 (CS) 引腳。 SPI 命令結構如表 1 所示。MAX14915的SPI模式為CPOL = 0 (CLK空閑= 0),CPHA = 0 (上升沿/第一沿對數據進行采樣),數據/命令需要先以MSB時鐘

芯片地址 突發位 注冊 -
地址
R/W 數據
2 位
A[1:0]
1 位
BRST[0]
4 位
R[3:0]
MSB 至 LSB
1 位
RW[0]
8 位
D[7:0]
MSB 至 LSB

有關SPI讀寫周期以及寄存器表和指令的更多詳細信息,請參考MAX14915和MAX14916數據資料

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

MAX14915 – 代碼應用示例

MAX14915設計用于支持終端設備的工業應用,如需要多個高邊開關的可編程邏輯控制器PLC)。支持16通道組隔離的典型應用電路采用單個MAX14483數字隔離器,如圖2所示。

poYBAGP0If2ANmzkAAEuQjMbXf4826.jpg?imgver=1

圖2.16通道高邊開關組隔離。

每個單獨的輸出可以驅動高達 1A 的電流,并具有單獨的開路、過流和過溫診斷

為了簡化需要電流隔離的系統,MAX14915支持菊花鏈和尋址SPI模式。

注意: 某些診斷功能僅在直接 SPI 或尋址 SPI 模式下可用,但在菊花鏈模式下不可用。詳情請參考MAX14915數據資料。

源代碼

本應用筆記提供了C源代碼示例,主要提供驅動器功能,用于訪問MAX14915中的多個寄存器,以實現配置、控制和診斷功能。所有軟件均使用MAX14915評估板進行實現和測試。客戶應僅將本文檔中的功能用作參考,并根據其應用程序中的微控制器和硬件實現設計自己的固件/軟件。

寄存器地址定義:

#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;

該測試程序等待MAX14915,直到它沒有報告任何故障,例如在上電MAX14915報告上電復位條件之后。接下來,對MAX14915進行初始化,以便報告任何故障,作為典型上電自檢程序的一部分,二進制計數器在8個通道上運行并打印故障條件。

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所需的功能,包括寄存器讀寫操作、CRC代碼生成和解碼以及錯誤標志輪詢。

//********************************************************************
//*
//* 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的診斷特性。在此示例中,僅打印錯誤條件。真正的應用程序可能必須采取進一步的操作:

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
}

結論

本應用筆記介紹了如何對MAX14915進行編程以驅動輸出和診斷故障條件。該代碼使用MAX14915EVKIT進行測試。工程師可以使用本應用筆記中提到的C代碼示例,快速輕松地實現常用微控制器和MAX14915之間的接口。

審核編輯:郭婷

聲明:本文內容及配圖由入駐作者撰寫或者入駐合作網站授權轉載。文章觀點僅代表作者本人,不代表電子發燒友網立場。文章及其配圖僅供工程師學習之用,如有內容侵權或者其他違規問題,請聯系本站處理。 舉報投訴
  • 微控制器
    +關注

    關注

    48

    文章

    7574

    瀏覽量

    151707
  • 芯片
    +關注

    關注

    456

    文章

    51004

    瀏覽量

    425208
  • SPI
    SPI
    +關注

    關注

    17

    文章

    1715

    瀏覽量

    91830
收藏 人收藏

    評論

    相關推薦

    16通道高壓模擬開關MAX14803A相關資料分享

    16通道高壓模擬開關MAX14803A資料下載內容主要介紹了:MAX14803A功能和特點MAX
    發表于 03-23 06:24

    16通道高壓模擬開關MAX14806相關資料分享

    16通道高壓模擬開關MAX14806資料下載內容主要介紹了:MAX14806功能和特點MAX14
    發表于 03-23 07:53

    16通道高壓模擬開關MAX14805資料推薦

    16通道高壓模擬開關MAX14805資料下載內容包括:MAX14805功能和特點MAX14805
    發表于 03-23 06:35

    16通道高壓模擬開關MAX14803相關資料下載

    16通道高壓模擬開關MAX14803資料下載內容包括:MAX14803功能和特點MAX14803
    發表于 03-26 06:01

    16通道高壓模擬開關MAX14802資料推薦

    16通道高壓模擬開關MAX14802資料下載內容包括:MAX14802功能和特點MAX14802
    發表于 03-31 06:43

    16通道高壓模擬開關MAX14800電子資料

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

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

    MAX306, MAX307 高精度、16通道/雙8通道、高性能、CMOS模擬多路復用器 &
    發表于 03-20 08:31 ?4050次閱讀
    <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通道、閃存配置系統監測器,提供非易失故障寄存器 MA
    發表于 04-05 06:00 ?1041次閱讀

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

    MAX11044, MAX11045, MAX11046 4/6/8通道16位、同時采樣ADC
    發表于 04-10 21:10 ?1592次閱讀
    <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>位同時采樣ADC

    MAX4968,MAX4968A 16通道線性高壓模擬開關

    MAX4968/MAX4968A是16通道線性度,電壓,雙向SPST
    發表于 07-03 09:14 ?3251次閱讀
    <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'>開關</b>

    8通道電子開關電路

    8通道電子開關電路,都是值得參考的設計。
    發表于 05-11 17:00 ?0次下載

    Maxim八通道開關/驅動器可大幅提升工業4.0應用體驗

    Maxim八通道開關/驅動器可對任意感性負載安全消磁,大幅提升工業4.0應用體驗 。 Maxim針對工業4.0應用聯合硅天下科技推出MAX
    發表于 07-11 10:18 ?948次閱讀

    如何編程 MAX14915/MAX14916 - 8 通道開關

    發表于 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'>開關</b>

    MAX14915通道、工業、開關CRC編程指南

    MAX14915為高性能、8通道、工業開關,具有豐富、先進的功能集。SPI接口允許微控制器監
    的頭像 發表于 02-21 16:14 ?1270次閱讀
    <b class='flag-5'>MAX14915</b>八<b class='flag-5'>通道</b>、工業、<b class='flag-5'>高</b><b class='flag-5'>邊</b><b class='flag-5'>開關</b>CRC<b class='flag-5'>編程</b>指南

    如何對MAX14915/16進行編程 - 8通道開關

    MAX149158通道開關。它支持8
    的頭像 發表于 06-13 16:29 ?993次閱讀
    如何對<b class='flag-5'>MAX14915</b>/<b class='flag-5'>16</b><b class='flag-5'>進行</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'>開關</b>
    主站蜘蛛池模板: 精品伊人久久香线蕉| 手机在线看片福利| 欧美二区三区| 你懂的网站在线观看网址| 免费看片aⅴ免费大片| 激情综合网激情| 播五月综合| 午夜视频在线观看国产| 日本加勒比在线播放| 高清在线观看视频| 中文字幕视频二区| 在线天堂bt种子资源| 天堂a| 美女视频黄视大全视频免费网址| 黄色超污网站| 午夜免费视频| 国产精品天天影视久久综合网| 色播影院性播免费看| 绝色村妇的泛滥春情| 亚洲ay| 欧美一级视频高清片| 国产欧美乱码在线看| 天天在线天天在线天天影视| 国产免费资源| 天天躁狠狠躁夜夜躁2021| 性欧美videofree视频另类| 欧美午夜色视频国产精品| 岛国片欧美一级毛片| 免费福利午夜影视网| 在线资源网| 色综合色综合色综合色综合| jlzzjlzz欧美大全| 老司机精品免费视频| 色偷偷成人网免费视频男人的天堂| 免费国产在线视频| 亚洲色图激情| 1024手机看片日韩| 99久久99久久久精品齐齐鬼色| 日本aaaa| 伊人久久影视| 视频在线观看网站|