can anybody share code of reading data from uart by using uart interrupt method
-
- Posts: 51
- Joined: Sat Mar 17, 2018 4:49 am
Re: can anybody share code of reading data from uart by using uart interrupt method
i tried replacing 20 / portTICK_RATE_MS with portMAX_DELAY but by using this it is waiting infinite time in that reading function.
here am sharing my code
#define TXD_PIN 1
#define RXD_PIN 3
void init() {
uart_config_t uart_config = {
.baud_rate = 115200,
.data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_DISABLE,
.stop_bits = UART_STOP_BITS_1,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE
};
uart_param_config(UART_NUM_0, &uart_config);
uart_set_pin(UART_NUM_0, TXD_PIN, RXD_PIN, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
uart_driver_install(UART_NUM_0, 1024, 1024, 0, NULL, 0);
}
void tx_task()
{
uint8_t *data = (uint8_t *) malloc(1024);
while (1) {
printf("hiiii\n");
int len = uart_read_bytes(UART_NUM_0, data, 1024,portMAX_DELAY);
printf("hello\n");
uart_write_bytes(UART_NUM_0, (const char *)data, len);
}
}
void app_main()
{
init();
xTaskCreate(tx_task, "uart_tx_task", 1024*2, NULL, 5, NULL);
}
here am sharing my code
#define TXD_PIN 1
#define RXD_PIN 3
void init() {
uart_config_t uart_config = {
.baud_rate = 115200,
.data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_DISABLE,
.stop_bits = UART_STOP_BITS_1,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE
};
uart_param_config(UART_NUM_0, &uart_config);
uart_set_pin(UART_NUM_0, TXD_PIN, RXD_PIN, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
uart_driver_install(UART_NUM_0, 1024, 1024, 0, NULL, 0);
}
void tx_task()
{
uint8_t *data = (uint8_t *) malloc(1024);
while (1) {
printf("hiiii\n");
int len = uart_read_bytes(UART_NUM_0, data, 1024,portMAX_DELAY);
printf("hello\n");
uart_write_bytes(UART_NUM_0, (const char *)data, len);
}
}
void app_main()
{
init();
xTaskCreate(tx_task, "uart_tx_task", 1024*2, NULL, 5, NULL);
}
-
- Posts: 51
- Joined: Sat Mar 17, 2018 4:49 am
Re: can anybody share code of reading data from uart by using uart interrupt method
ningappa BS wrote:i tried replacing 20 / portTICK_RATE_MS with portMAX_DELAY but by using this it is waiting infinite time in that reading function.
here am sharing my code
#define TXD_PIN 1
#define RXD_PIN 3
void init() {
uart_config_t uart_config = {
.baud_rate = 115200,
.data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_DISABLE,
.stop_bits = UART_STOP_BITS_1,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE
};
uart_param_config(UART_NUM_0, &uart_config);
uart_set_pin(UART_NUM_0, TXD_PIN, RXD_PIN, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
uart_driver_install(UART_NUM_0, 1024, 1024, 0, NULL, 0);
}
void tx_task()
{
uint8_t *data = (uint8_t *) malloc(1024);
while (1) {
printf("hiiii\n");
int len = uart_read_bytes(UART_NUM_0, data, 1024,portMAX_DELAY);
printf("hello\n");
uart_write_bytes(UART_NUM_0, (const char *)data, len);
}
}
void app_main()
{
init();
xTaskCreate(tx_task, "uart_tx_task", 1024*2, NULL, 5, NULL);
}
Re: can anybody share code of reading data from uart by using uart interrupt method
I am also interested in uart functions
Found reference to interrupt handler function
from https://esp-idf.readthedocs.io/en/v2.0/ ... #functions
Found reference to interrupt handler function
Code: Select all
esp_err_t uart_isr_register(uart_port_tuart_num, void (*fn)(void *), void *arg, int intr_alloc_flags, uart_isr_handle_t *handle, )
register UART interrupt handler(ISR).
Note
UART ISR handler will be attached to the same CPU core that this function is running on.
Return
ESP_OK Success
ESP_FAIL Parameter error
Parameters
uart_num: UART_NUM_0, UART_NUM_1 or UART_NUM_2
fn: Interrupt handler function.
arg: parameter for handler function
intr_alloc_flags: Flags used to allocate the interrupt. One or multiple (ORred) ESP_INTR_FLAG_* values. See esp_intr_alloc.h for more info.
handle: Pointer to return handle. If non-NULL, a handle for the interrupt will be returned here.
Re: can anybody share code of reading data from uart by using uart interrupt method
The docs you link here are for an older version of ESP-IDF, V2.0. In V3.0 (current stable release) the docs were rearranged, the equivalent docs page is now here:Deouss wrote:from https://esp-idf.readthedocs.io/en/v2.0/ ... #functions
http://esp-idf.readthedocs.io/en/v3.0/a ... /uart.html
To switch to the even newer master branch then you can use the version pop-up in the bottom left.
Are you sure the UART is receiving data correctly? Are all the pins configured and connected correctly? If you use the unmodified "UART echo" example, does this work?ningappa BS wrote:i tried replacing 20 / portTICK_RATE_MS with portMAX_DELAY but by using this it is waiting infinite time in that reading function.
Re: can anybody share code of reading data from uart by using uart interrupt method
Do you know if there is a PDF document of whole documentation?ESP_Angus wrote:
The docs you link here are for an older version of ESP-IDF, V2.0. In V3.0 (current stable release) the docs were rearranged, the equivalent docs page is now here:
http://esp-idf.readthedocs.io/en/v3.0/a ... /uart.html
To switch to the even newer master branch then you can use the version pop-up in the bottom left.
-
- Posts: 51
- Joined: Sat Mar 17, 2018 4:49 am
Re: can anybody share code of reading data from uart by using uart interrupt method
yes am sure UART working correctly, data receiving properly and unmodified echo example is working.ESP_Angus wrote:The docs you link here are for an older version of ESP-IDF, V2.0. In V3.0 (current stable release) the docs were rearranged, the equivalent docs page is now here:Deouss wrote:from https://esp-idf.readthedocs.io/en/v2.0/ ... #functions
http://esp-idf.readthedocs.io/en/v3.0/a ... /uart.html
To switch to the even newer master branch then you can use the version pop-up in the bottom left.
Are you sure the UART is receiving data correctly? Are all the pins configured and connected correctly? If you use the unmodified "UART echo" example, does this work?ningappa BS wrote:i tried replacing 20 / portTICK_RATE_MS with portMAX_DELAY but by using this it is waiting infinite time in that reading function.
http://esp-idf.readthedocs.io/en/v3.0/a ... /uart.html
in this doc there is no function sequence.
Re: can anybody share code of reading data from uart by using uart interrupt method
Click on Read the Docs (bottom left) and select Downloads PDF.Deouss wrote: Do you know if there is a PDF document of whole documentation?
-
- Posts: 51
- Joined: Sat Mar 17, 2018 4:49 am
Re: can anybody share code of reading data from uart by using uart interrupt method
ya it is there, is it there any driver code for uart interrupt method.
Re: can anybody share code of reading data from uart by using uart interrupt method
You can adapt the uart driver from esp-idf if it does not suits your needs.ningappa BS wrote:ya it is there, is it there any driver code for uart interrupt method.
Who is online
Users browsing this forum: Google [Bot], slaboure and 82 guests