Part Number: MSP432P401R
Tool/software: Code Composer Studio
Hi,
I developed a code on CCS for a booster pack I designed which has a ADC on the MSP432. The program just reads data from the ADC and stream it through the serial port on to the laptop from the msp432. There is something weird which is causing us a problem. When we load the code onto the MSP432 on a MAC and stream the data on a MAC, it works fine and similarly if we load the code onto the MSP432 on a windows machine and stream the data on a windows machine, it works fine. The problem arises when we load the code on one platform (say a MAC) and stream the data on a different platform (say a windows machine) then the stream rate drastically reduces. The rate reduces like 4-5 times.
So I started debugging and tried to find at what lines this is happening and if I comment the following lines in my code, it works fine cross platform (in the sense - load it on one OS and stream it on a different OS). And when I uncomment the following lines of code then the problem comes back. The following lines of code is just a cyclic buffer which is used for averages (down sampling the values).
// zero out the circular buffers at startup for (n=0; n<BUFLEN; n++) { sig0buf[n] = 0; sig1buf[n] = 0; sig2buf[n] = 0; sig0sum = 0; sig1sum = 0; sig2sum = 0; } // Initialize the circular buffers if (global_switch_mode) { // populate all elements of the circular buffers with the current samples for (n=0; n<BUFLEN; n++) { sig0buf[n] = sig0; sig1buf[n] = sig1; sig2buf[n] = sig2; } // compute the initial sum sig0sum = sig0*BUFLEN; sig1sum = sig1*BUFLEN; sig2sum = sig2*BUFLEN; // set the initial pointer to zero ptr = 0; // reset the global switch mode global_switch_mode = false; } // Average the raw data samples sig0sum = sig0sum - sig0buf[ptr] + sig0; // subtract oldest, add newest sig0buf[ptr] = sig0; // store the newest value sig0 = sig0sum / BUFLEN; // compute new average sig1sum = sig1sum - sig1buf[ptr] + sig1; // subtract oldest, add newest sig1buf[ptr] = sig1; // store the newest value sig1 = sig1sum / BUFLEN; // compute new average sig2sum = sig2sum - sig2buf[ptr] + sig2; // subtract oldest, add newest sig2buf[ptr] = sig2; // store the newest value sig2 = sig2sum / BUFLEN; // compute new average ptr = (ptr + 1) % BUFLEN; // increment pointer modulo the buffer length