Hi!
Now I have found a solution to my own problem. When QP is used with the mbed something weird happens when using analog reads, which makes the system freeze.
Workaround:
1. Power up the mbed's ADC twice, both in the constructor of the AI and in the BSP_init() method. If the power up in the constructor is omitted the mbed freezes at boot, and if the power up in the BSP_init() method is omitted the mbed freezes some time after boot.
-> The ADC is powered up using the command below (see lpc1768 user manual at http://www.nxp.com/documents/user_manual/UM10360.pdf p. 63 for more information):
LPC_SC->PCONP |= (1 << 12); //Set the PDADC bit residing in the 12th bit of the PCONP register
2. After the second power-up the mbed's read function in the mbed library works as documented. However, the QSPY output does not work totally as it should, i.e. in my case it does not print QSPY messages in the callback function when the read function is used.
-> To solve this I used the HighSpeedAnalogIn library by Shinichiro Nakamura, which does not cause the same behaviour, and which is available at:
http://mbed.org/users/shintamainjp/libraries/HighSpeedAnalogIn/lm3z05
Ask if you need further directions on getting the analog reads to work with mbed and QP. I might have forgotten to write something here and might be able to help.
- Axel
Hi!
I am trying to do read an analog input (multiple ones later on) and then display it on the screen using the mbed LPC1768 microcontroller and the QP/C++ framework http://www.state-machine.com/mbed/index.php.
My problem is that the analogin.read() function supplied in a mbed library totally freezes the execution of the QP. I tried to call the function from different places, i.e. low priority active objects, inside ISRs etc. but the execution always freezes when the read() function is called.
I could not find any examples on using the analog ins with mbed and QP. Without QP the reading is trivial.
I have tested that mbed functions AnalogOut & PwmOut works as they should, i.e. output the given values also with QP.
My questions are therefore:
I have also asked the questions below from the QP forum http://sourceforge.net/projects/qpc/forums/forum/668726/topic/5263150, and Miro suspected that:
Quote:
analogin.read() might poll a global flag set from the interrupt when the ADC conversion completes. For some reason, the interrupt might not run correctly when QP is present, hence the polling loop never returns.
This raises one more question:
Thank you in advance!
- Axel