Other Parts Discussed in Thread: MSP430FR2433
Tool/software:
Hello everyone!
I'm interfacing the MSP with MPU-6050 and the CCS811 gas sensor, and want to see the values via UART.
For this purpose, I coded two functions, one to convert the integer values to string and another to print using the UART module; in the main function, I made this way:
while (1) { acc_comm(); //int_to_string(xAccel, num); //uart_puts(num); //int_to_string(yAccel, num); //uart_puts(num); //int_to_string(zAccel, num); //uart_puts(num); gases_comm(); //int_to_string(co2Lvl, num); //uart_puts(num); //int_to_string(tvocLvl, num); //uart_puts(num); // do something with the data __delay_cycles(500000); }
When I uncomment the function calls, the communication fails.
I'd like to know what causes this issue to happen. I suppose that the I2C lines cannot be on idle, but don't have confirmations of this; any help of you guys will be very much appreciated.
For reference, I'll leave the two functions code here:
void int_to_string(int num, unsigned char *str) { unsigned char i = 0, j = 0; char aux[5]; do { aux[i++] = num % 10 + '0'; num /= 10; } while(num > 0); while(i--) { str[j++] = aux[i]; } str[j] = '\0'; } void uart_puts(unsigned char *str) { while(*str) { while(!(IFG2 & UCA0TXIFG)); UCA0TXBUF = *str++; } UCA0TXBUF = '\n'; }
Also, the configuration code of I2C and UART are the same of the examples in the TI developer zone.