digitaldanny / AudioEffectsGlove

A hand tracking glove that controls parameters of various audio effects.
1 stars 0 forks source link

C2000 HC-05 Slave API #57

Closed digitaldanny closed 3 years ago

digitaldanny commented 3 years ago

Complete

Also included in this PR

digitaldanny commented 3 years ago

The "NAME?" readback test passes on the C2000. The board reads back "+NAME:HC-05\r\n" from the device. In Waveforms, I was seeing that the baud rate was around 38.55kHz instead of 38.4kHz. It seems like this error amount is not giving the HC-05 problems, but it's good to keep this in mind.

Also, the sci_ex_loopback_interrupts project in the C2000Ware is not providing the baud rate I'd expect. As an input to SCI_setConfig, I had to shift the baud rate input over by 1. This bit shifting is done in demo/hc05.h lines 22-23.

#define BAUDRATE_38400      (38400<<1)
#define BAUDRATE_9600       (9600<<1)
digitaldanny commented 3 years ago

Created a unit test to confirm that wireless transmission works between master/slave HC-05s. The test involves 2 functions that must run at the same time - hc05.c -> hc05RwToMasterTest() on DSP side and TEST_hc05RwToSlave.cpp -> unitTest_hc05RwToSlave() on glove side.

Right now I am seeing data being (mostly) correctly transferred from master to slave. The only issue is that the final character is never received no matter what length message I send. A quick workaround is to just add an extra character at the end of the message on the master side.

Data is not transmitting correctly from slave back to master. My slave returns an "OK\n" message after receiving data correctly, but RX interrupt on the MSP432 never gets triggered. Still looking into this issue.

After this, I just need to run the test in a loop (maybe like 10k iterations) and create a percentage of correct transmissions on the slave side. This will determine if I need to add a checksum to the message protocol.

digitaldanny commented 3 years ago

Data is not transmitting correctly from slave back to master. My slave returns an "OK\n" message after receiving data correctly, but RX interrupt on the MSP432 never gets triggered. Still looking into this issue.

Breakpointing for a few seconds while waiting for master/slave pairing after powering the master HC-05 back on in CMD mode fixed the issue I was seeing. I am not sure why the DSP side was still receiving the data, but it looks like 2 way communication is functional now.

I am going to try using the STATE pin on the glove-side to programmatically determine when the device is connected to slave.

digitaldanny commented 3 years ago

Added loops for the read/write tests on glove/dsp sides. I'm not sure why, but the MSP432 is unable to receive the "OK" message again even though I wait for the STATE pin at the beginning of the test setup.

digitaldanny commented 3 years ago

Still trying to eliminate the problem receiving data from slave to master. Here's what I am going to try below.

digitaldanny commented 3 years ago

Logic analyzer on master HC-05's TX pin (sending data received from C2000).

Did this test. From the MSP432's receive side, I could see that the data was not being received by the master HC-05 correctly. Where I should be seeing consistent "OK\n" messages, I would see OOK\n, O, OOK, etc.. Occasionally, I would get the correct message.

This means that the MSP432's UART RX code is debugging the messages correctly. Either the C2000 is writing data incorrectly or one of the HC-05 modules are broken.

image

digitaldanny commented 3 years ago

Logic analyzer on slave HC-05's RX pin (receives data to transfer to MSP432).

Also completed this test. Looks like the C2000 is sending invalid messages. I think the HC-05 modules are both okay, and I just need to figure out what I am doing wrong with the C2000 uart code.

image

digitaldanny commented 3 years ago

Looks like adding a small software delay between transfers on the C2000 side fixed the issue. I ran a test with 500 iterations, and it passed with 100%. Merging to master.