I am new to PSOC 4 BLE and to Bluetooth in general and because we will use in the future the products from cypress I want to learn as much as possible. In one of the first test projects that I was working on in order to measure some parameters of the board I hit a problem regarding the ADC Seq. I am not able to put the code here(even if it is a test one) because of copy right issues but I will explain the project and how I conclude that the problem is with the ADC.
At the core the project has the examples from application note AN92584 : http://www.cypress.com/documentation/application-notes/an92584-designing-low-power-and-estimating-battery-life-ble
In the design (.cysch) I have the following: a RTC, a Pin for LED(SW), the ADC SAR and of course the BLE.
The BLE is Peripheral, Server and has a custom service with a big characteristic of 80 char values.
The RTC: is configured to generate an interrupt at every 32 seconds and uses the WCO Low Power and the Timer 2 WDT2.
The ADC SAR: has 4 input pins sets to (P3.0, P3.1, P3.2, P3.3) set as high impendence analog, VRef is internal 1.024 volts, single ended negative set to Vref, free running, Clock frequency 1kHz all using A clcks, INJ is not check as enabled.
The app should to the following: init ADC, and Disable the IRQ for ADC, init RTC; Process BLE events updates the characteristic of BLE and notify, and as a code for the RUN part of AN92584 do the following:
Then read all 4 adc chanels , process the values, and go to Deep sleep if possible(depending on the BLE). Every time the RTC elapses(32s) the above 3 lines of code + the reading of the adc and processing the value are executed.
I have observed that the ADC blocks at IsEndConversion and never exits. Why? I hope you will explain me if what I was doing is ok. It is a best practice to start and stop the ADC after each conversion + disable its interrupts? Are the pins for Analog correct set?
In all the examples that I saw the first 2 lines of code was executed before the infinite loop and then only the get result was called, but I do not need to have the ADC converting all the time but only at 32 s. Should I use the trigger mode and maybe someone can explain how?
I want to mention also that the code was tested without the ADC and it behaves ok, I can read the characteristic(of course I cannot see if it is correctly modified since the adc is not working), it enters correctly the sleep modes. the RTC sends correctly the interrupt at 32 s.
Thank you very much and hopefully I was clear in my text!