This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

PGA460-Q1: USART Communication on PGA460-Q1

Part Number: PGA460-Q1
Other Parts Discussed in Thread: PGA460, MSP430F5529, , MSP-EXP430F5529LP, ENERGIA

Hi,

I am using PGA460-Q1 with MSP430F5529 microcontroller for my application. I have been writing my custom code to interface with PGA460-Q1 through USART communication. I am able to send a write command and receive a response, but I get the diagnostic data i.e. First byte of response as 0XFF whatever might be the command. Also the recived checksum doesn't matches with my calculated checksum on receive operation. My checksum calculation is correct as I compared the checksum calculated by my c function with the PGA460 GUI checksum calculation and they matched for the transmit operation. To verify my comunication I wote to a register at address 0x40 with a value by Register Write Command (Cmd10) and in the next command i read the same register using CMd9. But diagnostic byte received was 0XFF and even the cheksum didn't match. Is there something which i am missing out for USART communication on PGA460?

Thanks

Nishant Sharma

  • Hi Nishant,

    Since you are using the MSP430F5529 microcontroller, have you explored the PGA460 Energia Library and Code Example download? This contains example code to run the MSP-EXP430F5529LP (same hardware as PGA460-Q1 EVM) in all available interface modes, including USART/SPI. I recommend that you install Energia and import this PGA460 library into Energia to run the GetDistance.ino sketch, which is a basic code example to configure the device settings, threshold times and levels, and loop-run a burst-and-listen command and ultrasonic measurement results response command to continuously report the latest time-of-flight converted to distance.

    The function details can be reviewed in the PGA460_USSC.cpp file, which separates the function execution by interface type (see switch-case #3 for SPI in each function). This code can resourceful as a guide to implementing/debugging your SPI implementation on the MSP430F5529 since it has already been tested for this specific microcontroller. After reviewing this material, let me know if you have any follow-up questions.

  • Hi Akeem,

    Thanks for your response. I was able to figure out the problem. I was unaware that before reading Ultrasonic Measurement Result I have to send Burst and Listen or listen command. I was testing individual command before writing Application Programming Layer. Now all the commands are giving proper response except for Echo Data Dump command(Cmd7). I think there is also some command pattern for successful Echo data dump read. Can you give some input what is the correct command sequence before sending command 7.

    Thanks 

    Nishant Sharma

  • Nishant,

    If you are using custom firmware, you will need to set the value of DATADUMP_EN.

    The echo data-dump function can be enabled for any of the four BURST/LISTEN or LISTEN ONLY commands and is enabled by the DATADUMP_EN bit in the EE_CNTRL register. The DATADUMP_EN bit is default disabled, which allows the Ultrasonic Measurement Result to update. When enabled (DATADUMP_EN= 1), and upon receiving a BURST/LISTEN or a LISTEN ONLY command, the PGA460-Q1 device holds the IO pin low for the entire record interval thus signaling the master MCU that data-dump cycle is in progress. When the data-dump cycle is complete the data can be extracted by the data dump read command.

    Note, only the UItrasonic Measurement Result or Echo Data Dump will update, but not both depedning on the value at DATADUMP_EN.

    Here is the first part of the  runEchoDataDump function from the PGA460 Energia library demonstrating a register write to set DATADUMP_EN=1 prior to initiating a BURST/LISTEN command:

    void pga460::runEchoDataDump(byte preset)
    {
    	if (comm != 1) // USART or OWU mode
    	{	
    		// enable Echo Data Dump bit
    		regAddr = 0x40;
    		regData = 0x80;
    		byte writeType = SRW; // default to single address register write (cmd10)
    		if(preset>16) // update to broadcast register write if broadcast TOF preset command given
    		{
    			writeType = BC_RW; // cmd22
    		}
    		
    		byte buf10[5] = {syncByte, writeType, regAddr, regData, calcChecksum(writeType)};
    		if (comm == 0 || comm == 2) // UART or OWU mode
    		{
    			pga460SerialFlush();
    			Serial1.write(buf10, sizeof(buf10));
    		}
    		if (comm == 3) // SPI mode
    		{
    			spiTransfer(buf10, sizeof(buf10));
    		}
    		delay(10);

  • Hi Akeem,

    Thanks for your response. I will try this approach. 

    Nishant Sharma