8 years, 2 months ago.

Unable to use TCP along with ADC

I have a TCP echo server program that works fine on my GR-PEACH-full.

But simply adding a declaration for an analog input pin ( AnalogIn ain2(A1); ) causes the program to crash with the following debug message:

mbed assertation failed: interrupts_disabled, file: C:\Jenkins\workspace\mbed-2-build-library\hal\common\mbed_critical.c, line 54

Can someone point me to why this is happening ? I am using the example code from https://developer.mbed.org/forum/mbed/topic/4630/ which uses EthernetInterface.lib and works fine by itself. Analog read also works fine by itself

Question relating to:

GR-PEACH is an Mbed enabled platform which combines the advantages of the Mbed ecosystem and Arduino UNO form factor.

Jithin BP

An different way to initialize analog inputs could be like this-

Initialize a pins to perform analog input and digital output fucntions AnalogIn ain0(A0); AnalogIn ain1(A1); AnalogIn ain2(A2); AnalogIn ain3(A3);

float a0_f, a1_f, a2_f, a3_f; as is done for ADC applications

Porting Code across platforms generally works in the digital domain but even functions like analog button presses may not make it over as user buttons make have differing functionality from board to board i.e. reset = sw1 on board1 but sw1 on board2 is user_input i.e. counter.

posted by XtrmDesignsLLC GRPeach 06 Sep 2016

2 Answers

8 years, 2 months ago.

Jithin BP

An different way to initialize analog inputs could be like this-

Initialize a pins to perform analog input and digital output fucntions AnalogIn ain0(A0); AnalogIn ain1(A1); AnalogIn ain2(A2); AnalogIn ain3(A3);

float a0_f, a1_f, a2_f, a3_f; as is done for ADC applications

Porting Code across platforms generally works in the digital domain but even functions like analog button presses may not make it over as user buttons make have differing functionality from board to board i.e. reset = sw1 on board1 but sw1 on board2 is user_input i.e. counter.

' AnalogIn ain1(A1); ' is the only line I had added, and that caused crashing. I didn't even have to read from the analog pin. Are you saying I will have to explicity declare all digital outputs also?

I check the GR Peach schematic very carefully, there are no shared pins between ethernet and A0-A5

posted by jithin bp 10 Sep 2016
8 years, 1 month ago.

I have also tried. And I also meet similar issue. I added "AnalogIn ain2 (A1);" to the following "main.cpp line 20".

Import programHTTPServer_echoback

Simple HTTP server example with EthernetInterface lib. access the mbed via any browser, mbed echo back http request header.

main.cpp line 20

AnalogIn ain2 (A1);  //Add this line


I do not know why, but when "mbed-dev.lib" is used instead of "mbed.lib", it works well.
The revision of the library I tried is as follows.

LibraryRevisionCommit message
mbed.lib127:25aea2a3f4e3Release 127 of the mbed library
mbed-dev.lib148:21d94c44109eThis updates the lib to the mbed lib v127

It seems the problem peculiar to GR-PEACH. Please wait a moment.
It isn't the problem peculiar to GR-PEACH. The same problem also occurred in "NUCLEO-144".

posted by Daiki Kato 20 Oct 2016

It was reported as the Issue.

There is a possibility that a problem occurs to the occasion using the "PlatformMutex" class and "mbed-rtos.lib". The following static memory is in the AnalogIn class.

static SingletonPtr _mutex;

This memory is static, so the size is decided at the time of "mbed.lib" build. The size of the "PlatformMutex class" will differ on whether the "MBED_CONF_RTOS_PRESE" has been defined. When "mbed.lib" created, "MBED_CONF_RTOS_PRESE" is undefined. When you build the sample, the value of the "MBED_CONF_RTOS_PRESE" is determined by whether or not to link the "mbed-rtos.lib".
Therefore, I think that does not work properly in the sample that contains the "mbed-rtos.lib".

posted by Daiki Kato 24 Oct 2016

The RTOS has been updated so this issue should now be fixed.

posted by Daiki Kato 10 Nov 2016