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

Color sensor pca20035

Dear, 

I am using thingy:91 pca20035 and try to test the color sensor BH1749NUC

I tried to run the /samples/sensor/bh1749

I got the output: 

SPM: NS image at 0xc000
SPM: NS MSP at 0x20020a78
SPM: NS reset vector at 0xde51
SPM: prepare to jump to Non-Secure image.
***** Booting Zephyr OS build v1.14.99-ncs3-snapshot2-1270-gb1d603491de8 *****
device is 0x20021d9c, name is BH1749
[00:00:00.004,913] [1B][0m<inf> BH1749: BH1749 initialized[1B][0m

I expected it will return the color in process(dev); but I got nothing. 

Do I need to do some "trigger" to enable sensor? 

Thanks, 

BR, 

Hoang Nguyen

Parents
  • The reason you're not getting any input is because it's stuck at process(..)→while(1)k_sem_take(..). In order for the program to continue from there, k_sem_give(..) has to be called (this is because the count it zero, and the give function will increase it, read more about semaphores here). In trigger_handler(..) this function is called, and it will allow the program to continue.

    When I ran the program, the trigger function was never called, I am not sure why, since sensor_trigger_set() executed without any errors. It might be something wrong with the configuration of the bh1479 sensor, and it will never trigger GPIO PIN 27.

    However, I was able to make the sensor work by disabling triggering, which can be done by setting CONFIG_BH1749_TRIGGER=n in prj.conf. Then you have to call sensor_sample_fetch_chan(..) followed by sensor_channel_get(..) at regular intervals.

    If you would like to use the sensor in interrupt mode, I can look into it.

    Best regards,

    Simon

  • Hello, yes I am here Slight smile

    Actually I changed it in SES, through Project→Configure nRF Connect...→(search for trigger in top right corner and unhooked the box "Trigger for BH1749"). But I think setting to (=n) it in prj.conf should do the same.

    I also used the master branch (not NCS v1.0.0).

    Did you put the file ncs\nrf\dts\bindings\sensor into ncs\zephyr\dts\bindings\sensor?

    I used the code in \ncs\nrf\samples\sensor\bh1749.

    Best regards,

    Simon

  • Thanks Simon, 

    I also used the master branch (not NCS v1.0.0).

    ja, I am using master branch also

    I will try ........................

  • Actually I changed it in SES, through Project→Configure nRF Connect...→(search for trigger in top right corner and unhooked the box "Trigger for BH1749"). But I think setting to (=n) it in prj.conf should do the same.

    Ja, you right, 

    I also used the master branch (not NCS v1.0.0).

    Ja, I am using the same branch

    Did you put the file ncs\nrf\dts\bindings\sensor into ncs\zephyr\dts\bindings\sensor?

    I just tried it, in ncs\zephyr\dts\bindings\sensor missed file rohm,bh1749.yaml 

    I used the code in \ncs\nrf\samples\sensor\bh1749.

    I am using the same one

    My result:

    Peripheral		Domain		Status
    00 NRF_P0		Non-Secure	OK
    01 NRF_CLOCK		Non-Secure	OK
    02 NRF_RTC1		Non-Secure	OK
    03 NRF_NVMC		Non-Secure	OK
    04 NRF_UARTE1		Non-Secure	OK
    05 NRF_TWIM2		Non-Secure	OK
    06 NRF_SPIM3		Non-Secure	OK
    07 NRF_TIMER0		Non-Secure	OK
    08 NRF_TIMER1		Non-Secure	OK
    09 NRF_TIMER2		Non-Secure	OK
    10 NRF_SAADC		Non-Secure	OK
    11 NRF_PWM0		Non-Secure	OK
    12 NRF_PWM1		Non-Secure	OK
    13 NRF_PWM2		Non-Secure	OK
    14 NRF_PWM3		Non-Secure	OK
    15 NRF_IPC		Non-Secure	OK
    16 NRF_VMC		Non-Secure	OK
    17 NRF_FPU		Non-Secure	OK
    18 NRF_EGU1		Non-Secure	OK
    19 NRF_EGU2		Non-Secure	OK
    20 NRF_GPIOTE1		Non-Secure	OK
    
    SPM: NS image at 0xc000
    SPM: NS MSP at 0x20020a70
    SPM: NS reset vector at 0xdda1
    SPM: prepare to jump to Non-Secure image.
    ***** Booting Zephyr OS build v1.14.99-ncs3-snapshot2-1270-gb1d603491de8 *****
    device is 0x20021d94, name is BH1749
    [00:0sensor_sample_fetch failed ret -5
    0:00.004,913] [1B][0m<inf> BH1749: BH1749 initialized[1B][0m
    [00:00:00.010,742] [1B][1;31m<err> BH1749: No valid data to fetch.[1B][0m
    

  • I built a secure application and modified the prj.conf as well:

    CONFIG_LOG=y
    CONFIG_I2C=y
    CONFIG_SENSOR=y
    CONFIG_BH1749=y
    CONFIG_BH1749_TRIGGER=y
    
    CONFIG_HAS_SEGGER_RTT=y
    CONFIG_USE_SEGGER_RTT=y
    CONFIG_RTT_CONSOLE=y
    CONFIG_UART_CONSOLE=n
    

    But I changed CONFIG_BH1749_TRIGGER in SES after, so it was eventually set to n

    I will see if I am able to recreate your error.

    Best regards,

    Simon

  • hi @Simon, 

    I changed the prj.conf as your:

    (added) 

    CONFIG_HAS_SEGGER_RTT=y
    CONFIG_USE_SEGGER_RTT=y
    CONFIG_RTT_CONSOLE=y
    CONFIG_UART_CONSOLE=n

    and ran again: 

    nothing come ( run NS)

    Peripheral		Domain		Status
    00 NRF_P0		Non-Secure	OK
    01 NRF_CLOCK		Non-Secure	OK
    02 NRF_RTC1		Non-Secure	OK
    03 NRF_NVMC		Non-Secure	OK
    04 NRF_UARTE1		Non-Secure	OK
    05 NRF_TWIM2		Non-Secure	OK
    06 NRF_SPIM3		Non-Secure	OK
    07 NRF_TIMER0		Non-Secure	OK
    08 NRF_TIMER1		Non-Secure	OK
    09 NRF_TIMER2		Non-Secure	OK
    10 NRF_SAADC		Non-Secure	OK
    11 NRF_PWM0		Non-Secure	OK
    12 NRF_PWM1		Non-Secure	OK
    13 NRF_PWM2		Non-Secure	OK
    14 NRF_PWM3		Non-Secure	OK
    15 NRF_IPC		Non-Secure	OK
    16 NRF_VMC		Non-Secure	OK
    17 NRF_FPU		Non-Secure	OK
    18 NRF_EGU1		Non-Secure	OK
    19 NRF_EGU2		Non-Secure	OK
    20 NRF_GPIOTE1		Non-Secure	OK
    
    SPM: NS image at 0xc000
    SPM: NS MSP at 0x20020f38
    SPM: NS reset vector at 0xdff1
    SPM: prepare to jump to Non-Secure image.
    

    Could you please share your code, is it possible?

    Thanks, 

    BR, 

    Hoang Nguyen

Reply
  • hi @Simon, 

    I changed the prj.conf as your:

    (added) 

    CONFIG_HAS_SEGGER_RTT=y
    CONFIG_USE_SEGGER_RTT=y
    CONFIG_RTT_CONSOLE=y
    CONFIG_UART_CONSOLE=n

    and ran again: 

    nothing come ( run NS)

    Peripheral		Domain		Status
    00 NRF_P0		Non-Secure	OK
    01 NRF_CLOCK		Non-Secure	OK
    02 NRF_RTC1		Non-Secure	OK
    03 NRF_NVMC		Non-Secure	OK
    04 NRF_UARTE1		Non-Secure	OK
    05 NRF_TWIM2		Non-Secure	OK
    06 NRF_SPIM3		Non-Secure	OK
    07 NRF_TIMER0		Non-Secure	OK
    08 NRF_TIMER1		Non-Secure	OK
    09 NRF_TIMER2		Non-Secure	OK
    10 NRF_SAADC		Non-Secure	OK
    11 NRF_PWM0		Non-Secure	OK
    12 NRF_PWM1		Non-Secure	OK
    13 NRF_PWM2		Non-Secure	OK
    14 NRF_PWM3		Non-Secure	OK
    15 NRF_IPC		Non-Secure	OK
    16 NRF_VMC		Non-Secure	OK
    17 NRF_FPU		Non-Secure	OK
    18 NRF_EGU1		Non-Secure	OK
    19 NRF_EGU2		Non-Secure	OK
    20 NRF_GPIOTE1		Non-Secure	OK
    
    SPM: NS image at 0xc000
    SPM: NS MSP at 0x20020f38
    SPM: NS reset vector at 0xdff1
    SPM: prepare to jump to Non-Secure image.
    

    Could you please share your code, is it possible?

    Thanks, 

    BR, 

    Hoang Nguyen

Children
Related