3 Replies Latest reply on Mar 31, 2020 6:24 AM by FlNa_4259441

    UDP example for PSoC 6 Wi-Fi BT Pioneer Kit




      Is there any example of an UDP broadcaster for the PSoC 6 Wi-Fi BT Pioneer Kit? The available examples for Modus Toolbox include only TCP clients/servers.


      I managed to implement an UDP broadcaster and stream data using this http://ultimaserial.com/avr_lwip_udp.html model but the processor throws an exception after a few seconds because of full memory. So my guess is that I don't free the memory properly. I tried both Raw API and Network connection programming models without major modifications from that site, but the behavior remains the same.


      The data I try to stream is received via DMA from an external ADC. I have 5 chained DMAs and after each RX DMA complete interrupt, I try to send the received data (216 bits) to my laptop from the network task (the only task I manually create). The DMAs trigger at about 4 KHz (250 microseconds) because that is the ADC sampling rate. Maybe this scenario is too much for the actual implementation?


      I am using Modus Toolbox + FreeRTOS + lwIP.


      Please let me know if you need any additional information.


      Thank you,


        • 1. Re: UDP example for PSoC 6 Wi-Fi BT Pioneer Kit

          Hi Florin,


          Unfortunately, we don't have an example for udp as of now. I will try to implement an example using a timed event of 250 microseconds to trigger a udp transmit. Once I am done, I will be able to have a little more clarity on this.


          Meanwhile, you can try using the netconn apis and try doing the transmit, may be based on a button press. Please check in that case, whether the processor throws an exception.

          • 2. Re: UDP example for PSoC 6 Wi-Fi BT Pioneer Kit

            Attached is a simple example that I tested with which seems to work okay with button interrupt. Please note that this example has not gone through standard Cypress code review process and something I just cooked up to test the mentioned scenario. if you choose to import the project, you can follow the steps mentioned in Sharing My Eclipse Project


            You can compare your application code with the one attached here to identify differences, if any. Next, I am going to emulate the timed event of 250 microseconds and test further. Will keep you posted with my findings.

            • 3. Re: UDP example for PSoC 6 Wi-Fi BT Pioneer Kit



              Thank you very much for your assistance. This example works fine for me, too. But, adapting it to my needs results into the same issue. I manage to transmit for several tens of seconds and then the fault occurs.


              The task that sends the UDP data is created as follows:


              /* Queue to Receive TCP packets */
              tcp_client_queue = xQueueCreate(TCP_CLIENT_TASK_QUEUE_LEN, sizeof(tcp_data_packet_t));
              BaseType_t xReturned;
              xReturned = xTaskCreate(tcp_client_task, "Network task", (1024*5), NULL,
                          1, &networkTaskHandle);
              if( xReturned != pdPASS )


              The task is define as:


              void tcp_client_task(void *arg)
                  struct netbuf *buf;
                  uint8_t * data;
                  tcp_task_started = true;
                      xQueueReceive(tcp_client_queue, &tcp_pkt_buf, portMAX_DELAY);
                      cyhal_gpio_write(P9_5, false);
                      buf = netbuf_new();
                      data = netbuf_alloc(buf, sizeof(tcp_pkt_buf));
                      memcpy (data, &tcp_pkt_buf, sizeof (tcp_pkt_buf));
                      netconn_send(conn, buf);
                      cyhal_gpio_write(P9_5, true);



              The tcp_client_queue is populated from a DMA interrupt, where I call xQueueSendToBackFromISR(). The frequency of the DMA interrupt can be either 4 or 8KHz.


              From my limited skills in ARM fault debugging, I determined that the INVSTATE bit from the CFSR register is set to 1 when the error occurs. One time the INVPC bit was set, but I couldn't reproduce this error any further.