XL74HC165 Parallel-2-Serail Controller

XL74HC165 Parallel-2-Serail Controller (SOP16)

( SN74LS165, CD74LS165 - DIP16 / SOP16 )

( 不频繁存取, 可以考虑 I2C I/O Expender  )
PCF8574/ T module (8bits Address *0x40~0x4E* )
PCF8574A   module (8bit address   *0x70~0x7E* )

XL74HC165

  • fmax : VCC 3.3V < 4.2MHz, VCC 4.5V < 21MHz.
  • Rising Edge active: Don’t care < Duty Cycle & Stability >
  • MSB First Out.
  • QH presented after Latch data
  • VCC 4.5V , Vih = 3.15 (min)

XL74HC165 Parallel-2-Serail Controller_第1张图片

Hardware Code

<2023/08/24 : UNTESTED CODE>

//Hardware Pin Define depend on circuit
sbit   hwInhibit         = 0xA3;     // Pin15   nCE
sbit   hwSerialIO      = 0xA2;     // Pin 9    MISO
sbit   hwSerialClock = 0xA1;     // Pin 2   SCLK
sbit   nLoad              = 0xA0;    // Pin 1   nLatch

// Private Function definition
void InitSerialIO( void);
void vRead74165( unsigned char *databuf);
void vReadSerailIO(unsigned char ucLength, unsigned char *databuf);

/***************************************************************************
*   InitSerialIO( void)   Initial hardware interface
*/
void InitSerialIO( void)
{
	hwInhibit  	     = 0;   //  Low for bypass or Hardware tight to ground. 
  	hwSerialIO      = 1;   //  Depend on MCU Input I/O stage
  	hwSerialClock = 1;   //  Rising edge active data shift out
  	nLoad             = 1 ;  //  1=Shift /  0=Load  
  
}
/***************************************************************************
*   vRead74165( unsigned char*)   Read 8bit data into buffer 
*/
// MSB First shift out
void vRead74165( unsigned char *databuf)
{	 unsigned char i; 
      for(  i = 0; i <8; i++)
        {  
           *databuf <<=1;   
           hwSerialClock = 0;   
           if( hwSerialIO ) { *databuf += 1; }  
           // Add delay here to prevent glitch if IO too fast
           hwSerialClock = 1;  // Rising Edge to shitt next bit out to QH
        }
}
/***************************************************************************
*  vReadSerailIO( ucLength,  *databuf)  Read  Multiple  
*/
void  vReadSerailIO(unsigned char ucLength, unsigned char *databuf)
{
      InitSerialIO( ); 
      nLoad = 0;  // Latch Data
      nLoad = 1 ; // Enable shift mode
      for(  ; ucLength >0; ucLength--)  vRead74165( databuf++); 
}

Example Code

#define TOTALCHIPS  60

extern void vReadSerailIO(unsigned char ucLength, unsigned char *databuf);
void main(void)
{
    unsigned char  ucSerilIO[ TOTALCHIPS ] 
    while(1)
    {
	    // Read All Chips
	    vReadSerailIO( TOTALCHIPS,  ucSerilIO );  
	      
	    // Parsing Data for process. 
	    // Mapping channel information and pin stage 
    }  
}

Hardware Xchange < BDFHGECA > Pin Xchange by Layout

/********************************************************************************************
*  unsigned char  xExchangeMapping( unsigned char )  Pin Xchange by Layout 
*/
#if 0
unsigned char  xExchangeMapping( unsigned char *databuf)
{     
     unsigned char ucTemp =0; 
     ucTemp += (*databuf >> 0) & 0x01;  //A
     ucTemp += (*databuf >> 6) & 0x02;  //B
     ucTemp += (*databuf << 1) & 0x04;  //C
     ucTemp += (*databuf >> 3) & 0x08;  //D
     ucTemp += (*databuf << 2) & 0x10;  //E
     ucTemp += (*databuf >> 0) & 0x20;  //F
     ucTemp += (*databuf << 3) & 0x40;  //G
     ucTemp += (*databuf << 3) & 0x80;  //H
     return ucTemp; 
}
#else
unsigned char  xExchangeMapping( unsigned char databuf)
{     
     unsigned char ucTemp =0; 
     ucTemp += (databuf >> 0) & 0x21;  // A & F
     ucTemp += (databuf >> 6) & 0x02;  //B
     ucTemp += (databuf << 1) & 0x04;  //C
     ucTemp += (databuf >> 3) & 0x08;  //D
     ucTemp += (databuf << 2) & 0x10;  //E
     ucTemp += (databuf << 3) & 0xC0;  // G & H
     return ucTemp; 
}
#endif

XL74HC165 Parallel-2-Serail Controller
芯片不好买, 嘉立创有卖, 运费贵。
<备份> 收集资料, 仅供参考。
数据剪辑自原厂 ( XINLUDA ) 规格书, 版权归原所有人拥有。
档案取自互联网!如有侵权或不适用情形, 请联系移除!
** 使用有风险, 请详阅原厂使用说明!
** 范例码为自用,请勿引用, Ctrl-C, Ctrl-V结果自行承担!

#电子零件

你可能感兴趣的:(笔记,零件,硬件,单片机)