CH455H 問題求助中?。。。。。。。。。。?!

目前我只用CH455H做為3X5 的鍵盤掃描 啟動鍵盤掃描后 鍵按下的中斷信號為低后一直保持為低或者隔很長一段時(shí)間才被拉高 有時(shí)候又是很快就高了 反正感覺就是很不穩(wěn)定 這是為什么呢 鍵值讀出來的都是亂的 求助各位前輩幫忙解決一下這個(gè)問題 MCU是STM32F103 但是不用中斷 直接讀一次鍵值都是對的 但是循環(huán)去讀又出亂了

/********************************************************************* * INCLUDES */ #include "CH455.H"

/********************************************************************* * FUNCTIONS */ void CH455_Init( void ) { CH455_MCU_IO_INIT();

CH455_IO_SDA_TG_OUTPUT(); CH455_IO_SDA_SET_HI(); CH455_IO_SCL_SET_HI(); }

static void CH455_BusStart( void ) { CH455_IO_SDA_TG_OUTPUT(); CH455_IO_SDA_SET_HI(); CH455_IO_SCL_SET_HI(); CH455_IO_MCU_WAIT_NS(100); CH455_IO_SDA_SET_LO(); CH455_IO_MCU_WAIT_NS(100); CH455_IO_SCL_SET_LO(); }

static void CH455_BusStop( void ) { CH455_IO_SDA_TG_OUTPUT(); CH455_IO_SDA_SET_LO(); CH455_IO_MCU_WAIT_NS(100); CH455_IO_SCL_SET_HI(); CH455_IO_MCU_WAIT_NS(100); CH455_IO_SDA_SET_HI(); }

static void CH455_WriteByte( unsigned char wByte ) { unsigned char i = 0;

CH455_IO_SDA_TG_OUTPUT(); for ( i = 0x80; i >= 0x01; i >>= 1 ) { if ( i & wByte ) CH455_IO_SDA_SET_HI(); else CH455_IO_SDA_SET_LO(); CH455_IO_MCU_WAIT_NS(100); CH455_IO_SCL_SET_HI(); CH455_IO_MCU_WAIT_NS(100); CH455_IO_SCL_SET_LO(); } //Recieve ACK CH455_IO_SDA_SET_HI(); CH455_IO_MCU_WAIT_NS(100); CH455_IO_SCL_SET_HI(); CH455_IO_MCU_WAIT_NS(100); CH455_IO_SCL_SET_LO(); }

void CH455_Write( unsigned char byte1, unsigned char byte2 ) { CH455_BusStart(); CH455_WriteByte( byte1 );

CH455_WriteByte( byte2 );

CH455_BusStop(); }

void CH455_Read( unsigned char wByte, unsigned char *rByte ) { unsigned char i = 0, readByte = 0;

CH455_BusStart();

CH455_WriteByte( wByte );

CH455_IO_SDA_TG_INPUT();

for ( i = 0x80; i >= 0x01; i >>= 1 ) { CH455_IO_MCU_WAIT_NS(100); CH455_IO_SCL_SET_HI(); CH455_IO_MCU_WAIT_NS(100); CH455_IO_SCL_SET_LO(); if ( CH455_IO_SDA_GET() ) readByte |= i; } CH455_BusStop();

*rByte = readByte; }


所謂的循環(huán)讀取鍵值數(shù)據(jù)錯誤是鍵值讀取出來和前一次不一樣還是其他的問題。你能否拿示波器看下波形。我需要看下你發(fā)出去的數(shù)據(jù)是否正確。


只有登錄才能回復(fù),可以選擇微信賬號登錄

国产91精品新入口,国产成人综合网在线播放,九热这里只有精品,本道在线观看,美女视频a美女视频,韩国美女激情视频,日本美女pvp视频