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.

having trouble receiving correct data using modified acclerometer code

Hi guys,

so i read through the post here and think i understood most of the stuff: http://e2e.ti.com/support/low_power_rf/f/660/t/84691.aspx.

I was able to connect my ez430 target board wirelessly (so without the usb dongle) to my laptop (i have a bt adapter built into my laptop) by modifying appl_sdk.h (YAY!). For starters just to test that i can wirelessly send data correctly i changed the contents of appl_acceleromenter_read_spp_send. I simply replaced it with:

void appl_acceleromenter_read_spp_send(UCHAR dev_index)
{
 

 /* sdk_accelerometer_read(appl_accelerometer_buffer,
                           sizeof(appl_accelerometer_buffer)
        );


    appl_spp_write(dev_index, appl_accelerometer_buffer,
                   sizeof(appl_accelerometer_buffer)
        );
  */
 
      UCHAR test[4];
test[0]= 00000000;
test[1]=00000000;
test[2]=00000000;
test[3]=00000000;

 
      appl_spp_write(dev_index, test,
                    sizeof(test)
        );
}

So basically, im just sending it a bunch of zero's. I use the included keyboard gen app to test the incoming data from the target board. I had to modify the keyboard gen since it expects accelerometer data and thus behaves as so. I got microsoft visual studios 2010 C++ to modify the keyboard_events_generator.c (is there a better way?) i debugged and built the appl so that it is changed to reflect what i want...just printing the raw data (which should all be zero's). I notice that the code that prints the data is mostly in the if (packet_pointer == 4) statement that starts at line 593 in the program. My modified if (packet_pointer== 4) statement is found at the end of this post.

Despite changing the keyboard gen code to print raw data (or at least so i think) im not getting the right data outputted from the command console. i changed the comport.txt file to the com port that my bt device was assigned (7). Despite this this is what im getting in my command console from the keyboard_events appl:

Ignore the final result data part.

 

packet 0 data = 0, packet 1 data = 0

packet 2 data = 0,packet 3 data = 0

final result data = 0

packet 0 data = 0, packet 1 data = 85

packet 2 data = 85, packet 3 data = 5

final result data = 21765

packet 0 data = 0, packet 1 data = 0

packet 2 data = 0,packet 3 data = 0

final result data = 0

packet 0 data = 0, packet 1 data = 85

packet 2 data = 85, packet 3 data = 5

final result data = 21765

packet 0 data = 0, packet 1 data = 0

packet 2 data = 0, packet 3 data = 0

final result data = 0

The first set of data is always correct..but then the data turns inconsistent alternating between outputting zero's or 85's and 5's..I've attached my modified keyboard_events.c code as well. Can someone please help me?? Perhaps there is an easier way to print out the raw data from my target board? Im not really familiar with using hyperterminal or putty with bluetooth..

if (packet_pointer == 4) // Complete Packet
                {                  
                    /* Valid Packet */
                   
                       
                        /* Reset pointer for next packet */
                        packet_pointer = 0;
                        toread = 4;

                        printf ("packet 0 data = %ld, packet 1 data = %ld\n", packet[0], packet[1]);
                        printf ("packet 2 data = %ld, packet 3 data = %ld\n", packet[2], packet[3]);

                        pos_x = packet[0];
                        pos_x <<= 8;
                        pos_x |= packet[1];
                        pos_x <<=8;
                        pos_x |= packet[2];
                        pos_x <<= 8;
                        pos_x |= packet[3];
                        printf ("final result data = %ld\n", pos_x);

                }

  • For some reason my spaces in between lines aren't showing up in my original post...i tried editing it too and it still comes out as one paragraph. Sorry for the horrible format. Let me know if how i can fix it or i can just email you the original post with the spaces..
  • Wesley,

    I would suggest using hyperterminal or putty as a first step to ensuring that the data is being received. The two programs show you the characters that are being received. These are mainly ASCII characters. Look at the Ascii Printable characters table here:

    http://en.wikipedia.org/wiki/ASCII

    You can send those(such as numbers and letters) and easily see them. Configure Hyperterminal/Putty for 9600 baud with 8 data bits, 1 stop bits and no parity and no hardware flow control.

     

    Gustavo

  • I've tried putty and configured it com7 and the other setup as you mentioned. however, it just prints out a bunch of: U's. this corresponds to 101 0101. So i guess this indicates my keyboard gen program is working...since 101 0101 equals 85 in dec. However, the question is why my target board is outputting 85... There shouldn't be anything calling the BT_spp_send function besides void appl_acceleromenter_read_spp_send(UCHAR dev_index). In there i clearly have:

     

          UCHAR test[4];
    test[0]= 00000000;
    test[1]=00000000;
    test[2]=00000000;
    test[3]=00000000;

     
          appl_spp_write(dev_index, test,
                        sizeof(test)
            );

     

    Any ideas? appreciate any help

    oh, i managed to fix my post above and putting spaces by clearing my cache hehe

  • Wesley,

     

    In appl_spp.c there is a function called appl_spp_notify_cb. Look for  case SPP_RECVD_DATA_IND:

    This is the point at which if data is received by the receiver, it will be sent to the USB. So here you can see exactly what's happenning at the receiving end. You could put a breakpoint and look directly at the data received.

     

    Gustavo