Sending and recieving 24 bit of ADC data in UART

Sensacell

Joined Jun 19, 2012
3,432
You have not mentioned the bandwidth of this data stream, if it's not really high, I would encode the data as ASCII hex with a carriage return delimiter, then you can observe the data using any dumb terminal program.

This makes debugging so much easier, you can see what's going wrong in minutes instead of days.
 

Irving

Joined Jan 30, 2016
3,843
While it doesn't fix the MATLAB end, you could make you code more readable/efficient by:

removing the intrinsic delay call __delay_cycles(x) and using the UART TX ready bit. Modify putDataToUart like this:

Code:
static void putDataToUart(uint8_t byte){
    while (!(UCA0IFG&UCTXIFG));   // USCI_A0 TX buffer ready?
    UCA0TXBUF = byte; // transmit byte
}
replacing the three 'if' statements with:

Code:
putDataToUart('/');
switch(crChannel) {
    case 0: putDataToUart('A');
        break;
    case 1: putDataToUart('B');
        break;
    case 2: putDataToUart('C');
        break;
    }
putDataToUart('/');
 
Top