UART: Unable to transmit data
Posted: Fri Jun 30, 2017 4:56 pm
I'm using an MTK3339 GPS module with UART1 in pins 16 (RX) & 17 (TX). I can read data coming from the GPS module with uart_read_bytes() on UART1, but I can't get uart_write_bytes() working to send commands to the module (see: https://cdn-shop.adafruit.com/datasheets/PMTK_A11.pdf). I've tried sending data as a char array, and also sending the <CR><LF> as litterally "<CR><LF>" or \r\n which I believe mean the same thing. Neither have worked so far, so hopefully someone smarter than me can tell me what I'm doing wrong .
Code: Select all
uart_config_t uart_config = {
.baud_rate = 9600,
.data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_DISABLE,
.stop_bits = UART_STOP_BITS_1,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
.rx_flow_ctrl_thresh = 122,
};
uart_param_config(UART_NUM_1, &uart_config);
uart_set_pin(UART_NUM_1, 17, 16, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
uart_driver_install(UART_NUM_1, BUF_SIZE * 2, 0, 0, NULL, 0);
uint8_t* writeBuf = (uint8_t*) "$PMTK220,10000*2F\r\n";
uart_write_bytes(UART_NUM_1, (const char*)writeBuf, 0);
unsigned char buf[BUF_SIZE];
while(1) {
int size = uart_read_bytes(UART_NUM_1, buf, BUF_SIZE, 1000 / portTICK_RATE_MS);
if (size >0) {
printf("%s", buf);
}
}