TI工程师您好!
问题1: 我用FR6989调试时 I2C通讯时一使能I2C模块,程序一运行 EUSCI_B_I2C_enable(uint16_t baseAddress)时状态寄存器UCB0STATW的UCBBUSY 就置1,所以程序就运行到uint16_t EUSCI_B_I2C_isBusBusy(uint16_t baseAddress)检测到I2C总线占用就无法运行到后面的程序,
我调试很久找不出原因 I2C不论是用P3.1 P3.2或改用P4.0 P4.1都提示状态寄存器UCB0STATW的UCBBUSY 是1,。
后来又出现下面的问题(问题2),换了3块板子调试2个MSP_FET仿真器都无法进入调试界面,请TI工程师帮我看下问题是出在哪里?非常感激!
谢谢!
Susan Yang:
请问您现在使用的是TI的launchpad还是您自己的板子?是使用TI例程还是自己的程序?
若是TI例程的话,能否给出例程名称?
Susan Yang:
关于第一个问题,您先参考一下
e2e.ti.com/…/581257
关于第二个问题,您是否有使用uniflash看一下,先排除板子本身硬件或者连接部分的问题。另外您的CCS/IAR版本是多少?
灰小子:
1、建议提供下相关的代码,这个问题是软件原因的可能居多。或者你先运行官网的iic例程测试一下。
2、第二个问题一般是硬件问题,建议重点检查仿真相关接口的连接情况和相关走线。
user3883938:
回复 Susan Yang:
Susan Yang :
您好 !程序是根据TI例程调用FR5xx6xx I2C库
开始我用的是MSP430FR6972 的板子自己layout 和触摸MCU msp430fr2522 I2C通讯,调试出现这个问题,I2C是根据例程例子,只是例子的I2C的SDA SCL用的是P4.0 P4.1我改为6972的P3.1 P3.0,出现这个问题我又用FR6989的板子直接运行TI例程
也还是一样,后来又出现了问题2,FR6989是我以前另个项目的板子运行那个程序没问题的,现在运行这个程序后就无法进入调试界面,我用的IIAR 7.12的编译器,出现问题后我又用以前的IAR6.2也是一样。
谢谢您们的回复。
user3883938:
回复 灰小子:
灰小子,谢谢您的回复,问题1的现象我刚回复susan Yang描述了,问题2 我用的硬件板子以前是运行是没问题的,只是前天才出现的,是否mcu IC被损坏或仿真器的JTAG接口芯片被锁死,但是仿真器我运行别的板子又没问题,只是运行F6989才会有这个问题。
Susan Yang:
回复 user3883938:
您现在是想master发送multiple bytes?driverlib内的程序可以参考下面的代码。
总线bus一直是busy的,一直到stop bit 置位您不需要这样调用 isBusBusy
第2个问题的话,应该是您板子的硬件问题
/* --COPYRIGHT--,BSD* Copyright (c) 2017, Texas Instruments Incorporated* All rights reserved.** Redistribution and use in source and binary forms, with or without* modification, are permitted provided that the following conditions* are met:** *Redistributions of source code must retain the above copyright*notice, this list of conditions and the following disclaimer.** *Redistributions in binary form must reproduce the above copyright*notice, this list of conditions and the following disclaimer in the*documentation and/or other materials provided with the distribution.** *Neither the name of Texas Instruments Incorporated nor the names of*its contributors may be used to endorse or promote products derived*from this software without specific prior written permission.** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.* --/COPYRIGHT--*/ #include "driverlib.h"//****************************************************************************** //! This example shows how to configure the I2C module as a master for //! multi byte transmission in interrupt driven mode. The address of the slave //! module is set in this example. //! //!Demo - EUSCI_B0 I2C Master TX multiple bytes to MSP430 Slave //! //!Description: This demo connects two MSP430's via the I2C bus. The master //!transmits to the slave. This is the MASTER CODE. It cntinuously //!transmits an array of data and demonstrates how to implement an I2C //!master transmitter sending multiple bytes using the USCI_B0 TX interrupt. //!ACLK = n/a, MCLK = SMCLK = BRCLK = default DCO = ~1.045MHz //! //!/|\/|\ //!MSP430FR596910k10kMSP430FR5969 //!slave||master //!-----------------||----------------- //!-|XINP1.6/UCB0SDA|<-|----+->|P1.6/UCB0SDAXIN|- //!||||| //!-|XOUT|||XOUT|- //!|P1.7/UCB0SCL|<-+------>|P1.7/UCB0SCL| //!|||| //! //! This example uses the following peripherals and I/O signals.You must //! review these and change as needed for your own board: //! - I2C peripheral //! - GPIO Port peripheral (for I2C pins) //! - SCL2 //! - SDA //! //! This example uses the following interrupt handlers.To use this example //! in your own application you must add these interrupt handlers to your //! vector table. //! - USCI_B0_VECTOR. ////****************************************************************************** //***************************************************************************** // //Set the address for slave module. This is a 7-bit address sent in the //following format: //[A6:A5:A4:A3:A2:A1:A0:RS] // //A zero in the "RS" position of the first byte means that the master //transmits (sends) data to the selected slave, and a one in this position //means that the master receives data from the slave. // //***************************************************************************** #define SLAVE_ADDRESS 0x48uint8_t TXData =0;// Pointer to TX data uint8_t TXByteCtr;void main(void) {WDT_A_hold(WDT_A_BASE);//Set DCO frequency to 1MHzCS_setDCOFreq(CS_DCORSEL_0,CS_DCOFSEL_0);//Set ACLK = VLO with frequency divider of 1CS_initClockSignal(CS_ACLK,CS_VLOCLK_SELECT,CS_CLOCK_DIVIDER_1);//Set SMCLK = DCO with frequency divider of 1CS_initClockSignal(CS_SMCLK,CS_DCOCLK_SELECT,CS_CLOCK_DIVIDER_1);//Set MCLK = DCO with frequency divider of 1CS_initClockSignal(CS_MCLK,CS_DCOCLK_SELECT,CS_CLOCK_DIVIDER_1);// Configure Pins for I2C//Set P1.6 and P1.7 as Secondary Module Function Input./** Select Port 1* Set Pin 6, 7 to input Secondary Module Function, (UCB0SIMO/UCB0SDA, UCB0SOMI/UCB0SCL).*/GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P1,GPIO_PIN6 + GPIO_PIN7,GPIO_SECONDARY_MODULE_FUNCTION);/** Disable the GPIO power-on default high-impedance mode to activate* previously configured port settings*/PMM_unlockLPM5();EUSCI_B_I2C_initMasterParam param = {0};param.selectClockSource = EUSCI_B_I2C_CLOCKSOURCE_SMCLK;param.i2cClk = CS_getSMCLK();param.dataRate = EUSCI_B_I2C_SET_DATA_RATE_400KBPS;param.byteCounterThreshold = 0;param.autoSTOPGeneration = EUSCI_B_I2C_NO_AUTO_STOP;EUSCI_B_I2C_initMaster(EUSCI_B0_BASE, ¶m);//Specify slave addressEUSCI_B_I2C_setSlaveAddress(EUSCI_B0_BASE,SLAVE_ADDRESS);//Set Master in receive modeEUSCI_B_I2C_setMode(EUSCI_B0_BASE,EUSCI_B_I2C_TRANSMIT_MODE);//Enable I2C Module to start operationsEUSCI_B_I2C_enable(EUSCI_B0_BASE);EUSCI_B_I2C_clearInterrupt(EUSCI_B0_BASE,EUSCI_B_I2C_TRANSMIT_INTERRUPT0 +EUSCI_B_I2C_NAK_INTERRUPT);//Enable master Receive interruptEUSCI_B_I2C_enableInterrupt(EUSCI_B0_BASE,EUSCI_B_I2C_TRANSMIT_INTERRUPT0 +EUSCI_B_I2C_NAK_INTERRUPT);while(1){__delay_cycles(1000);// Delay between transmissionsTXByteCtr = 4;// Load TX byte counterTXData = 0;while (EUSCI_B_I2C_SENDING_STOP == EUSCI_B_I2C_masterIsStopSent(EUSCI_B0_BASE));EUSCI_B_I2C_masterSendMultiByteStart(EUSCI_B0_BASE,TXData++);__bis_SR_register(CPUOFF + GIE);// Enter LPM0 w/ interrupts// Remain in LPM0 until all data// is TX'd// Increment data byte} }//------------------------------------------------------------------------------ // The USCIAB0TX_ISR is structured such that it can be used to transmit any // number of bytes by pre-loading TXByteCtr with the byte count. Also, TXData // points to the next byte to transmit. //------------------------------------------------------------------------------ #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__) #pragma vector=USCI_B0_VECTOR __interrupt #elif defined(__GNUC__) __attribute__((interrupt(USCI_B0_VECTOR))) #endif void USCIB0_ISR(void) {switch(__even_in_range(UCB0IV, USCI_I2C_UCBIT9IFG)){case USCI_NONE:// No interrupts break;break;case USCI_I2C_UCALIFG:// Arbitration lostbreak;case USCI_I2C_UCNACKIFG:// NAK received (master only)//resend start if NACKEUSCI_B_I2C_masterSendStart(EUSCI_B0_BASE);break;case USCI_I2C_UCTXIFG0:// TXIFG0// Check TX byte counterif (TXByteCtr){EUSCI_B_I2C_masterSendMultiByteNext(EUSCI_B0_BASE, TXData++);// Decrement TX byte counterTXByteCtr--;}else{EUSCI_B_I2C_masterSendMultiByteStop(EUSCI_B0_BASE);// Exit LPM0__bic_SR_register_on_exit(CPUOFF);}break;default:break;} }
灰小子:
回复 user3883938:
现在msp430的jtag熔丝,都是电子熔丝,都是可以使用仿真器来恢复的。所以不存在锁死的问题。
至于mcu是不是损坏了,这个只要没有接过较高的电压或者其他恶劣情况,msp430也不太容易坏的。