[solved] why nonstop process paused - no continuous output

User avatar
rudi ;-)
Posts: 1698
Joined: Fri Nov 13, 2015 3:25 pm

Re: why nonstop process paused - no continuous output

Postby rudi ;-) » Fri Nov 18, 2016 2:59 am

WiFive wrote:Did you try to add fflush(stdout)?
if we use the delay, then it works:

Code: Select all

void app_main()
{
	
	nvs_flash_init();
	/// system_init();
	uint32_t counts = 0;
	while (-1) {
		printf("Counter: %10d\r", counts);
		fflush(stdout);
		counts++;
	       vTaskDelay(10 / portTICK_PERIOD_MS);	
	}
if we not use a delay,

Code: Select all

void app_main()
{
	
	nvs_flash_init();
	/// system_init();
	uint32_t counts = 0;
	while (-1) {
		printf("Counter: %10d\r", counts);
		fflush(stdout);
		counts++;
	       // vTaskDelay(10 / portTICK_PERIOD_MS);	
	}
then the "app_main Task" or "new Task" paused several times

if the delay is to small, then it the same effect

i think, the delay must be greater as the double clock cylces for the instructions,
can it be this?

delay of 10 is ok
delay of 5 is to small - same effect
delay of 7 same, 8 same, 9 same, to small,
10 is perfect for this .

perfect for me YouTube Video

txs WiFive for helpful tip

best wishes
rudi ;-)
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

User avatar
rudi ;-)
Posts: 1698
Joined: Fri Nov 13, 2015 3:25 pm

[solved] why nonstop process paused - no continuous output

Postby rudi ;-) » Fri Nov 18, 2016 3:41 am

Short ADC Test YouTube Video

Code: Select all


#include <stdio.h>
#include <stdlib.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "soc/rtc_io_reg.h"
#include "esp_wifi.h"
#include "esp_event_loop.h"
#include "esp_system.h"
#include "nvs_flash.h"

enum adc1_pad { 
	ADC1_GPIO36 = 0,
	ADC1_GPIO37,
	ADC1_GPIO38,
	ADC1_GPIO39, 
	ADC1_GPIO32,
	ADC1_GPIO33,
	ADC1_GPIO34,
	ADC1_GPIO35 
};
 
enum adc1_atten {
	ADC1_ATTEN_0DB = 0,
	ADC1_ATTEN_3DB,
	ADC1_ATTEN_6DB,
	ADC1_ATTEN_12DB
};


uint32_t adc1_read(enum adc1_pad pad, enum adc1_atten att);


void app_main()
{
	nvs_flash_init();
	/// system_init(); 
	uint32_t counts = 0;
	while (-1) {
		printf("ESP32 onchip ADC1 (IO34) = %4d   count: %10d\r", adc1_read(ADC1_GPIO34, ADC1_ATTEN_12DB), counts);
		fflush(stdout);
		counts++;
	       vTaskDelay(10 / portTICK_PERIOD_MS);	
	}
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: [solved] why nonstop process paused - no continuous output

Postby WiFive » Fri Nov 18, 2016 4:33 am

If portTICK_PERIOD_MS = 10 then delay < 10 is 0

User avatar
rudi ;-)
Posts: 1698
Joined: Fri Nov 13, 2015 3:25 pm

Re: [solved] why nonstop process paused - no continuous output

Postby rudi ;-) » Fri Nov 18, 2016 11:20 am

WiFive wrote:If portTICK_PERIOD_MS = 10 then delay < 10 is 0
WiFive - this would be the next step, thanks for support!

https://github.com/espressif/esp-idf/bl ... cro.h#L252

Code: Select all

#define portTICK_PERIOD_MS			( ( TickType_t ) 1000 / configTICK_RATE_HZ )
https://github.com/espressif/esp-idf/bl ... fig.h#L159

Code: Select all

#define configTICK_RATE_HZ				( CONFIG_FREERTOS_HZ )
..
..
/* Default clock rate for simulator */
//#define configCPU_CLOCK_HZ				80000000

CONFIG_FREERTOS_HZ
http://www.freertos.org/a00110.html

Code: Select all


/* ? lib - define ? - esptool ? */ 
/* ;-) */ 
/* you find this in the sdkconfig over make menuconfig */

CONFIG_FREERTOS_HZ=100

tick_rate_CONFIG_FREERTOS_HZ.png
tick_rate_CONFIG_FREERTOS_HZ.png (18.64 KiB) Viewed 6675 times
help:
help_tick_rate_FREERTOS.png
help_tick_rate_FREERTOS.png (6.65 KiB) Viewed 6674 times
btw note:
corect SYMBOL is "FREERTOS_HZ"
we define in sdk this as "CONFIG_FREERTOS_HZ"

hope all details are here now

:ugeek:


btw , WiFive, what you think?
( perhabs for later for CAN - only if Jeroen can give us more input ) :

Code: Select all


struct AMessage
 {
	char ucMessageID;
	char ucData[ 20 ];
 } xMessage;

 uint32_t ulVar = 10UL;

 void vATask( void *pvParameters )
 {
 QueueHandle_t xQueue1, xQueue2;
 struct AMessage *pxMessage;

	// Create a queue capable of containing 10 uint32_t values.
	xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) );

	// Create a queue capable of containing 10 pointers to AMessage structures.
	// These should be passed by pointer as they contain a lot of data.
	xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );

	// ...

	if( xQueue1 != 0 )
	{
		// Send an uint32_t.  Wait for 10 ticks for space to become
		// available if necessary.
		if( xQueueSendToFront( xQueue1, ( void * ) &ulVar, ( TickType_t ) 10 ) != pdPASS )
		{
			// Failed to post the message, even after 10 ticks.
		}
	}

	if( xQueue2 != 0 )
	{
		// Send a pointer to a struct AMessage object.  Don't block if the
		// queue is already full.
		pxMessage = & xMessage;
		xQueueSendToFront( xQueue2, ( void * ) &pxMessage, ( TickType_t ) 0 );
	}

	// ... Rest of task code.
 }

txs

best wishes
rudi ;-)
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

User avatar
rudi ;-)
Posts: 1698
Joined: Fri Nov 13, 2015 3:25 pm

Re: why nonstop process paused - no continuous output

Postby rudi ;-) » Tue Jan 16, 2018 12:40 pm

WiFive wrote:Did you try to add fflush(stdout)?
( only for the protocol )
now i must check this again now
but "CAN" is done in the meantime :) so UART theme is done too :))

best wishes
rudi ;-)
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

Who is online

Users browsing this forum: Baidu [Spider] and 98 guests