Tool/software: Code Composer Studio
Hey everyone, am working on developing some navigation tools for an underwater project, my main task at this stage is to test the accuracy of an echo-sounder used to measure the water depth or for more tasks as you can check on the link below where you can find the Ping Sonar that i work with :
https://www.bluerobotics.com/store/sensors-sonars-cameras/sonar/ping-sonar-r2-rp/
This device have some measurement series that i need to read using UART communication through an MSP430F5529 Launchpad, for doing that i have developed a basic UART driver as you see below :
#include <msp430.h>
#include <stdint.h>
#include <stdio.h>
#define TXnotRX 0 //transmitter = 1, receiver = 0
#define loopBack
// char myString[] = {"A"};
// char *txData = myString;
uint32_t rxData=0;
//char offsetTab = 0;
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // Stop WDT
P3SEL |= BIT3 | BIT4; // Assign P3.3 to UCA0TXD and...
P3DIR |= BIT3; // P3.4 to UCA0RXD
UCA0CTL1 |= UCSWRST; // **Put state machine in reset**
UCA0CTL1 |= UCSSEL_1; // CLK = ACLK
UCA0BR0 |= 0x03; // 0x0332kHz/9600=3.41 (see User's Guide)
UCA0BR1 = 0x00; //
UCA0MCTL = UCBRS_3|UCBRF_0; // Modulation UCBRSx=3, UCBRFx=0
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
UCA0IE |= UCRXIE; // Enable USCI_A0 RX interrupt
__enable_interrupt();
//while (1){
//#if TXnotRX
// UCA0TXBUF = *txData++;
//#endif
// }
}
// UART ISR
#pragma vector=USCI_A0_VECTOR
__interrupt void USCI_A0_ISR(void)
{
switch(__even_in_range(UCA0IV, 4))
{
case 0:break; // Vector 0 - no interrupt
case 2: // Vector 2 - RXIFG
while (!(UCA0IFG & UCTXIFG)); // USCI_A0 TX buffer ready?
rxData = UCA0RXBUF;
//#ifdef loopBack
// loop back
// UCA0TXBUF = UCA0RXBUF; // TX -> RXed character
// #endif
break;
case 4:break; // Vector 4 - TXIFG
default: break;
}
}
The main problem that i can't read the data in the RX buffer, the output format providing by the sonar is u32, am asking is there any proposition to read the data from the Ping sonar device ?
Regards,
Zouhir EROUCH,
