<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic k65 project not recognised pthread_tdata type in MQX Software Solutions</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/k65-project-not-recognised-pthread-tdata-type/m-p/1628280#M18792</link>
    <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I'm trying to create a small project in which two different threads (send_command and received_buffer) are launched and executed simultaneously within the main function (two infinite while loops) which are used respectively to send and receive buffers from the UART (I'm using the TWRK65F180M evaluation board).&lt;/P&gt;&lt;P&gt;The code is as follows:&lt;/P&gt;&lt;P&gt;#include &amp;lt;stdio.h&amp;gt;&lt;BR /&gt;#include &amp;lt;stdint.h&lt;BR /&gt;&amp;gt; #include &amp;lt;stdlib.h&amp;gt;&lt;BR /&gt;#include &amp;lt;unistd.h&amp;gt;&lt;BR /&gt;#include &amp;lt;pthread.h&amp;gt;&lt;BR /&gt;#include &amp;lt;fcntl.h&amp;gt;&lt;/P&gt;&lt;P&gt;#include "board.h"&lt;BR /&gt;#include "fsl_uart_driver.h"&lt;BR /&gt;#include "fsl_clock_manager.h"&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;const uint8_t buffer[] = {0x55,0x02,0x01,0x00,0x00,0x03};&lt;BR /&gt;const uint8_t buffer_rx[1];&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;int main (void)&lt;BR /&gt;{&lt;BR /&gt;uint32_t byteCountBuff = 0;&lt;BR /&gt;uint32_t byteCountBuff_Rx = 0;&lt;/P&gt;&lt;P&gt;pthread_t thread1, thread2;&lt;BR /&gt;int iret1, iret2;&lt;/P&gt;&lt;P&gt;uart_state_t uart2State;&lt;BR /&gt;uart_state_t uart1State;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;uart_user_config_t uart2Config = {&lt;BR /&gt;.bitCountPerChar = kUart8BitsPerChar,&lt;BR /&gt;.parityMode = kUartParityDisabled,&lt;BR /&gt;.stopBitCount = kUartOneStopBit,&lt;BR /&gt;.baudRate = 115200U&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;uart_user_config_t uart1Config = {&lt;BR /&gt;.bitCountPerChar = kUart8BitsPerChar,&lt;BR /&gt;.parityMode = kUartParityDisabled,&lt;BR /&gt;.stopBitCount = kUartOneStopBit,&lt;BR /&gt;.baudRate = 2000000U //BaudRate = 2MHz&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;// Enable clock for PORTs, setup board clock source, config pin&lt;BR /&gt;hardware_init();&lt;/P&gt;&lt;P&gt;// Call OSA_Init to setup LP Timer for timeout&lt;BR /&gt;OSA_Init();&lt;/P&gt;&lt;P&gt;// Initialize the uart module with base address and config structure&lt;BR /&gt;UART_DRV_Init(BOARD_DEBUG_UART_INSTANCE, &amp;amp;uart2State, &amp;amp;uart2Config);&lt;BR /&gt;UART_DRV_Init(UART1_IDX, &amp;amp;uart1State, &amp;amp;uart1Config);&lt;/P&gt;&lt;P&gt;// Inform to start blocking example&lt;BR /&gt;byteCountBuff = sizeof(buffer);&lt;BR /&gt;byteCountBuff_Rx = sizeof(buffer_rx);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;iret1 = pthread_create( &amp;amp;thread1, NULL, received_buffer, NULL);&lt;BR /&gt;iret2 = pthread_create( &amp;amp;thread2, NULL, send_command, NULL);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;int send_command(void)&lt;BR /&gt;{&lt;BR /&gt;while(1)&lt;BR /&gt;{&lt;BR /&gt;UART_DRV_SendDataBlocking(UART1_IDX, buffer, byteCountBuff, 1000u);&lt;BR /&gt;delay_ms(100000);&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;int received_buffer(void)&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;while(true)&lt;BR /&gt;{&lt;BR /&gt;// Call received API&lt;BR /&gt;UART_DRV_ReceiveData(UART1_IDX, buffer_rx, byteCountBuff_Rx);&lt;/P&gt;&lt;P&gt;// Wait until we receive a character&lt;BR /&gt;while (kStatus_UART_RxBusy == UART_DRV_GetReceiveStatus(UART1_IDX, NULL)){}&lt;/P&gt;&lt;P&gt;// Echo received character&lt;BR /&gt;UART_DRV_SendData(BOARD_DEBUG_UART_INSTANCE, buffer_rx, byteCountBuff_Rx);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;//funzione per attendere tot ms prima della prossima operazione.&lt;BR /&gt;void delay_ms(int times)&lt;BR /&gt;{&lt;BR /&gt;int x;&lt;BR /&gt;for (x=times; x&amp;gt;0; x--)&lt;BR /&gt;{&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;The problem is that when I go to compile the project, the compiler doesn't recognize the pthread_t datatype and the pthread_create function. I thought including the &amp;lt;pthread.h&amp;gt; library would fix the problem, but it didn't. Could anyone&lt;BR /&gt;advise what other library to include or a way to fix this recognition problem?&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
    <pubDate>Wed, 05 Apr 2023 13:27:29 GMT</pubDate>
    <dc:creator>matteocrulli92</dc:creator>
    <dc:date>2023-04-05T13:27:29Z</dc:date>
    <item>
      <title>k65 project not recognised pthread_tdata type</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/k65-project-not-recognised-pthread-tdata-type/m-p/1628280#M18792</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I'm trying to create a small project in which two different threads (send_command and received_buffer) are launched and executed simultaneously within the main function (two infinite while loops) which are used respectively to send and receive buffers from the UART (I'm using the TWRK65F180M evaluation board).&lt;/P&gt;&lt;P&gt;The code is as follows:&lt;/P&gt;&lt;P&gt;#include &amp;lt;stdio.h&amp;gt;&lt;BR /&gt;#include &amp;lt;stdint.h&lt;BR /&gt;&amp;gt; #include &amp;lt;stdlib.h&amp;gt;&lt;BR /&gt;#include &amp;lt;unistd.h&amp;gt;&lt;BR /&gt;#include &amp;lt;pthread.h&amp;gt;&lt;BR /&gt;#include &amp;lt;fcntl.h&amp;gt;&lt;/P&gt;&lt;P&gt;#include "board.h"&lt;BR /&gt;#include "fsl_uart_driver.h"&lt;BR /&gt;#include "fsl_clock_manager.h"&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;const uint8_t buffer[] = {0x55,0x02,0x01,0x00,0x00,0x03};&lt;BR /&gt;const uint8_t buffer_rx[1];&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;int main (void)&lt;BR /&gt;{&lt;BR /&gt;uint32_t byteCountBuff = 0;&lt;BR /&gt;uint32_t byteCountBuff_Rx = 0;&lt;/P&gt;&lt;P&gt;pthread_t thread1, thread2;&lt;BR /&gt;int iret1, iret2;&lt;/P&gt;&lt;P&gt;uart_state_t uart2State;&lt;BR /&gt;uart_state_t uart1State;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;uart_user_config_t uart2Config = {&lt;BR /&gt;.bitCountPerChar = kUart8BitsPerChar,&lt;BR /&gt;.parityMode = kUartParityDisabled,&lt;BR /&gt;.stopBitCount = kUartOneStopBit,&lt;BR /&gt;.baudRate = 115200U&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;uart_user_config_t uart1Config = {&lt;BR /&gt;.bitCountPerChar = kUart8BitsPerChar,&lt;BR /&gt;.parityMode = kUartParityDisabled,&lt;BR /&gt;.stopBitCount = kUartOneStopBit,&lt;BR /&gt;.baudRate = 2000000U //BaudRate = 2MHz&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;// Enable clock for PORTs, setup board clock source, config pin&lt;BR /&gt;hardware_init();&lt;/P&gt;&lt;P&gt;// Call OSA_Init to setup LP Timer for timeout&lt;BR /&gt;OSA_Init();&lt;/P&gt;&lt;P&gt;// Initialize the uart module with base address and config structure&lt;BR /&gt;UART_DRV_Init(BOARD_DEBUG_UART_INSTANCE, &amp;amp;uart2State, &amp;amp;uart2Config);&lt;BR /&gt;UART_DRV_Init(UART1_IDX, &amp;amp;uart1State, &amp;amp;uart1Config);&lt;/P&gt;&lt;P&gt;// Inform to start blocking example&lt;BR /&gt;byteCountBuff = sizeof(buffer);&lt;BR /&gt;byteCountBuff_Rx = sizeof(buffer_rx);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;iret1 = pthread_create( &amp;amp;thread1, NULL, received_buffer, NULL);&lt;BR /&gt;iret2 = pthread_create( &amp;amp;thread2, NULL, send_command, NULL);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;int send_command(void)&lt;BR /&gt;{&lt;BR /&gt;while(1)&lt;BR /&gt;{&lt;BR /&gt;UART_DRV_SendDataBlocking(UART1_IDX, buffer, byteCountBuff, 1000u);&lt;BR /&gt;delay_ms(100000);&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;int received_buffer(void)&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;while(true)&lt;BR /&gt;{&lt;BR /&gt;// Call received API&lt;BR /&gt;UART_DRV_ReceiveData(UART1_IDX, buffer_rx, byteCountBuff_Rx);&lt;/P&gt;&lt;P&gt;// Wait until we receive a character&lt;BR /&gt;while (kStatus_UART_RxBusy == UART_DRV_GetReceiveStatus(UART1_IDX, NULL)){}&lt;/P&gt;&lt;P&gt;// Echo received character&lt;BR /&gt;UART_DRV_SendData(BOARD_DEBUG_UART_INSTANCE, buffer_rx, byteCountBuff_Rx);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;//funzione per attendere tot ms prima della prossima operazione.&lt;BR /&gt;void delay_ms(int times)&lt;BR /&gt;{&lt;BR /&gt;int x;&lt;BR /&gt;for (x=times; x&amp;gt;0; x--)&lt;BR /&gt;{&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;The problem is that when I go to compile the project, the compiler doesn't recognize the pthread_t datatype and the pthread_create function. I thought including the &amp;lt;pthread.h&amp;gt; library would fix the problem, but it didn't. Could anyone&lt;BR /&gt;advise what other library to include or a way to fix this recognition problem?&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2023 13:27:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/k65-project-not-recognised-pthread-tdata-type/m-p/1628280#M18792</guid>
      <dc:creator>matteocrulli92</dc:creator>
      <dc:date>2023-04-05T13:27:29Z</dc:date>
    </item>
  </channel>
</rss>

