**** ORIGNAL POST CAN BE IGNORED. SEE NEXT REPLY FOR UPDATE ****
I’m having some difficulty setting up a UART connection on the Daisy Patch Submodule. Ultimately I would like to communicate between a Daisy Patch Submodule and a Rasberry Pi, but for now I am just attempting to transmit messages to a USB serial converter.
So far I’ve been able to Transmit messages from Daisy only about 10% of the time. Seemingly at random, the USB serial converter will begin receiving transmitted messages, but usually nothing happens at all. When the serial usb does receive my transmitted messages and I print them in a PD patch, they are not as expected. I’m not sure if the error is how I send them on the Daisy side or how I decode them.
I should add though that every time I make a DmaTransmit() call on the Daisy PatchSm, it returns result of OK, even if the serial usb converter does not appear to receive anything
Below is all of my code related to the UartHandler and DmaTransmit/DmaReceive calls. Is there something in my config that may be causing issues or am I not properly setting up my transmit and receive buffers? I’m new to hardware and UART and any help is greatly appreciated.
/** UART Communication */
UartHandler uart_handler;
uint8_t uart_receive_buffer;
size_t uart_buffer_size = 512;
uint8_t uart_transmit_buffer[512];
int main(void)
{
/** UART communication config */
UartHandler::Config uart_config;
uart_config.baudrate = 9600;
uart_config.periph = UartHandler::Config::Peripheral::USART_1;
uart_config.stopbits = UartHandler::Config::StopBits::BITS_1;
uart_config.parity = UartHandler::Config::Parity::NONE;
uart_config.mode = UartHandler::Config::Mode::TX_RX;
uart_config.wordlength = UartHandler::Config::WordLength::BITS_8;
uart_config.pin_config.rx = {DSY_GPIOB, 15}; // (USART_1 RX) PatchSM pin A9
uart_config.pin_config.tx = {DSY_GPIOB, 14}; // (USART_1 TX) PatchSM pin A8
/** UART communication initialization */
uart_handler.Init(uart_config);
uart_handler.DmaReceive(&uart_receive_buffer, uart_buffer_size, NULL, NULL, NULL);
uart_handler.DmaReceiveFifo();
while(1) {
std::string transmit_message = "gr/107/0.5/15\n"; // test message
std::vector<uint8_t> transmit_vector(transmit_message.begin(), transmit_message.end()); // copy test message to uint8_t vector
UartHandler::Result result = uart_handler.DmaTransmit(&transmit_vector[0], transmit_message.length(), NULL, NULL, NULL);
if (result == UartHandler::Result::OK) {
hw.PrintLine("OK TRANSMIT");
} else {
hw.PrintLine("ERROR TRANSMIT");
}
hw.Delay(2000);
}
}