This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Build zephyr.elf versus Build solution

I can see in Segger Embedded Studio v4.52 under the Build Tab, there are two methods to build the project.

1- Build > Build zephyr/zephyr.elf

2- Build > Build solution

What is the difference between the two methods?

Kind regards

  • Hi Heidi,

    Thank you for your answers.

    So the difference is that the ´[channel_id]´ is the index into the channel array (AIN1 has index 0, AIN2 has index 1 etc.) and ´[input_positive]´ (which is the channel input) is the specific analog input, so AIN1 and AIN2.  

    If channel_id = 0 i.e. index zero into the channel array gets AIN1 then what is the index for channel AIN0?

    I have not finished reading your answers but I thought I ask this question in case it affects my understanding of the remainder of your answer.

    Kind regards

    Mohamed

  • Another thing I wanted to clarify by using the custom binding of the sample as an example, is this line:

    Fullscreen
    1
    io-channels = <&adc 0>, <&adc 1>;
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    As you can see, the io-channels are ´[&adc 0]´ and ´[&adc 1]´ which maps the ADC peripheral to channel 0 and 1. This just maps the ADC node to the analog input of channel 0 and the analog input of channel 1, which is AIN1 and AIN2, which then maps to GPIO pin P0.04 and P0.05 on the PDK, according to this table describing the mapping of analog pins on the nRF5340 PDK.

    According to the PCA10095 schematics of the nRF5340 PDK  (nRF5340-QKAA) pin 4 on P0.04 is AIN0 not AIN1.

    I have already raised this issue with Martin Lesund about three weeks ago and he said he will get this corrected. There seems to be some discrepancy between the user guide and the schematics. The latter is correct.

    So, this means channel_id = 0 i.e. index zero into the channel array points to AIN0.

    Kind regards

    Mohamed

  • So, this means channel_id = 0 i.e. index zero into the channel array points to AIN0.

    Since it seems we have the channel_id index offset by one in the nRF5340PDK, does it mean the examples referred to will not work as expected?

    According to the PCA10095_schematics of the nRF5340PDK pin P0.28 is AIN7. So, I connected a potentiometer to pins: P0.28, VDD, GND and tried to run the light intensity controller example but the adc did not work with this configuration code.

    #define ADC_1ST_CHANNEL_ID 7
    #define ADC_1ST_CHANNEL_INPUT NRF_SAADC_INPUT_AIN7

    So, I looked closely to pin P0.28 on the back of the pdk board and realised that P0.28 is actually labelled (A2). So, I changed the config to,

    #define ADC_1ST_CHANNEL_ID 2
    #define ADC_1ST_CHANNEL_INPUT NRF_SAADC_INPUT_AIN2

    and Bingo! it works. So, it seems that for the nRF5340PDK the values used for ADC_1ST_CHANNEL_ID  and ADC_1ST_CHANNEL_INPUT must the same. Any comments?

    Kind regards

    Mohamed

  • Hi!

    You know what, I misunderstood the description of channel_id. Sorry about that.

    At a closer look: "This value primarily identifies the channel within the ADC API". So the value of the channel_id does not matter (in the range of 0 to 7) as long as it is used consistently to identify that channel. This explains why channel ID 0 is used for AIN0 and channel 2 is used for AIN2, here.

    My mistake, sorry for the confusion! There is no channel id offset and the sample should work as expected.

    Yes, the table I linked to is apparently incorrect, so this is the correct pin mapping. 

    AIN0 P0.04
    AIN1 P0.05
    AIN2 P0.06
    AIN3 P0.07
    AIN4 P0.25
    AIN5 P0.26
    AIN6 P0.27
    AIN7 P0.28

    Learner said:
    Bingo! it works.

     Did it work with the analog device plugged into GPIO pin 28 or pin 6?

    If it was pin 28, could you attach the file with the path build_folder/zephyr/zephyr.dts just so I can confirm this?

    Again, sorry for the confusion. 

    Best regards,

    Heidi

  • Hi Heidi,

    No problem, we are all learning in the process.

    At a closer look: "This value primarily identifies the channel within the ADC API". So the value of the channel_id does not matter (in the range of 0 to 7) as long as it is used consistently to identify that channel. This explains why channel ID 0 is used for AIN0 and channel 2 is used for AIN2, here.

    I am not sure I understand what you are trying to say here.

    I understand the need to configure which analog pin is being used but I am still not clear on which one of these two macros is doing this job. If as you said it is ADC_1ST_CHANNEL_INPUT then why is ADC_1ST_CHANNEL_ID needed?

    The best way to understand what channel_id does is to see where it is used in the driver code. There is a driver function called channel_setup but I could not locate it. Could you please ask your colleagues developers to point us where in the driver code this function that uses channel_id and channel_input is.  

    Thank you.

    Kind regards

    Mohamed

Related