第1页共23页I2CArbitration7A软件设计第一部分原理图1.1FPGA_80A_ExternalTimer.SchDocRSTINT_NMIPAI[7..0]PDI[7..0]DATAI_TMRI[7..0]RD_TIMERPCO[7..0]PBI[7..0]PAO[7..0]PDO[7..0]PBO[7..0]PCI[7..0]WR_TIMERDATAO_TMR[7..0]CLKADDR[15..0]S1MCU_TSK80.SchDocCLKRSTDATA[7..0]ADDR[3..0]LINEBUSYSTROBELCD_ELCD_RWLCD_RSLCD_DATA_TRILCD_DATAO[7..0]LCD_DATAI[7..0]U9LCD16X2ACLK_1MHZRSTKEY[3..0]VALIDKEYCOL[3..0]ROW[3..0]U12KEYPADACLKRSTDATAI[7..0]DATAO[7..0]ADDR[2..0]WRRDINTTAGATEATBGATEBTB_OVU7TMR3GNDVCCVCCLCD_EP89P89LCD_RWP166P166LCD_RSP164P164LCD_DB[7..0]P88,P87,P86,P84,P83,P82,P81,P75P88,P87,P86,P84,P83,P82,P81,P75LCD_LIGHTP94P942x16LiquidCrystalDisplayKP_COL[3..0]P102,P98,P97,P96P102,P98,P97,P96KP_ROW[3..0]P101,P100,P99,P95P101,P100,P99,P9512abc3defCD654ghijklmnoFE0AB789pqrstuvwxyz*+#^(CLK_BRDP182P182TEST_BUTTONP3P3CLK_REFP185P185VCCTCKTMSTDITDOTRSTJTAG.JTAGJTAGJTAGJTAGJTAG..JTAG_NEXUS_TMSP10P10JTAG_NEXUS_TCKP9P9JTAG_NEXUS_TDOP11P11JTAG_NEXUS_TDIP8P8CLK_REFCLK_BRDTEST_BUTTONRSTCLK_100KHZCLK_1MHZCLKU_CLOCKSCLOCKS.SCHDOCPCO[7..0]PBI[7..0]PAI[7..0]PAO[7..0]PBO[7..0]KEY[3..0]PDO[7..0]ValidKeyClearKeyPadPDI[7..0]PCI[7..0]LCD_ADDR[3..0]LCD_DATA[7..0]LCD_LINELCD_STROBELCD_BUSYPS1PortSplitters.SchDoc[2..0][2..0][7..0][7..0]U10IOBUF8B$0000-$3FFFProgram/DataMemory(Only0-3FFFinstantiated)$4000-$4003Ports$8000-$8007TimerRegisters$C000-$FFFFUnused第2页共23页1.2FPGA_80A_ExternalTimer.;...............................................................................PORT_BASE.equ0x4000PORTA.equPORT_BASE+0PORTB.equPORT_BASE+1PORTC.equPORT_BASE+2PORTD.equPORT_BASE+3;..............................................................................;..............................................................................TIMER_BASE.equ0x8000TCON_ID.equTIMER_BASE+0TMOD_ID.equTIMER_BASE+1TL0_ID.equTIMER_BASE+2TL1_ID.equTIMER_BASE+3TH0_ID.equTIMER_BASE+4TH1_ID.equTIMER_BASE+5;..............................................................................;..............................................................................KeyPadInput.equPORTA;InputBits[3..0]=KeyID;Bit4=StatusKeyPadControl.equPORTA;OutputBit0=Reset;..............................................................................;..............................................................................LCD_Data.equPORTB;LCD_Status.equPORTB;InputBit0=BusyLCD_Address.equPORTC;OutputBits[3..0]=OffsetonLine;Bit4=LineNo.LCD_Control.equPORTD;OutputBit0=Strobe第3页共23页;..............................................................................;..............................................................................CurrentChar.equ0x0075CounterChar.equ0x0076CurrentMsgO.equ0x0077CurrentPos.equ0x0078DoubleChar.equ0x0079KeyPadChar.equ0x007BFPressDet.equ0x007CExtTCounter.equ0x007DIntTCounter.equ0x007FTimerRelEn.equ0x0080;..............................................................................;..............................................................................;bitpositionsBP0.equ0x00BP1.equ0x01BP2.equ0x02BP3.equ0x03BP4.equ0x04BP5.equ0x05BP6.equ0x06BP7.equ0x07;..............................................................................第4页共23页;................................................................................SectionText1,Code,at(0000H)JPMainProc;...............................................................................;................................................................................SectionText3,Code,at(0066H)JPNonMaskableInt;...............................................................................;................................................................................SectionText4,Code,at(0300H);...............................................................................MainProc:;...............................................................................LDSP,0x1FFFCALLResetKeypadLDA,0x00LD(LCD_Control),ALDA,0x00LD(FPressDet),ALD(ExtTCounter),ALDA,0xFFLD(IntTCounter),ALDE,0x00CALLMsg_To_Display_Base_On_EJPMainLoop第5页共23页;...............................................................................;...............................................................................MainLoop:;...............................................................................CALLScanKeyPadForFirstCharLDA,(FPressDet)BITBP0,AJPZ,MainLoopCALLClearLCDLDE,0x01CALLMsg_To_Display_Base_On_ECALLSend_Char_On_Pos_17CALLSend_Char_On_Pos_18CALLTimer0Mode1InitCALLTimer0ReloadCALLTimer0StartMainLoopF:CALLCheckKeyPadCharFor1or2or3or4JPMainLoopF;...............................................................................;...............................................................................NonMaskableInt:;...............................................................................PUSHBCPUSHAFPUSHDEPUSHIXLDA,(TimerRelEn)CP0x00第6页共23页JPNZ,NonMaskableIntReloadDisCALLTimer0ReloadNonMaskableIntReloadDis:CALLTimer0StartLDA,(IntTCounter)DECAJPNZ,NonMaskableIntRETLD(IntTCounter),ACALLDecCounterCALLSend_Char_On_Pos_17CALLSend_Char_On_Pos_18POPIXPOPDEPOPAF