i cannot make the BH1790GLC module work. it seems it only AVR platform library is available for the timer2 library

i cannot make the BH1790GLC module work. it seems it only AVR platform library is available for the timer2 library

  • Hi Weiwei2,

    The BH1790GLC device that you mentioned, is it the optical sensor for heart rate monitor application? If it doesn't have a library for GR-PEACH, looks like you need to code from scratch. I think the device operates in I2C protocol.

    JB
    RenesasRulz Forum Moderator
  • In reply to JB:

    Hi

    Certainly Flexietimer2 is not supported on Web Compiler, but Mstimer2 is supported.

    I confirmed below example on Web Compiler. Could you try that after importing attached zip?

    BH1790GLC.zip

     

     

    /*****************************************************************************
    BH1790GLC.ino

    Copyright (c) 2016 ROHM Co.,Ltd.

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    THE SOFTWARE.
    ******************************************************************************/
    #include <Arduino.h>
    #include <Wire.h>
    #include <BH1790GLC.h>
    #include <MsTimer2.h>
    #include <stdio.h>

    BH1790GLC bh1790glc;
    volatile bool timer_flg;
    char str[100];

    void timer_isr(void);

    void setup() {
    byte rc;

    timer_flg = false;
    Serial.begin(115200);
    while (!Serial);

    Wire.begin();
    Wire.setFrequency(400000L);

    rc = bh1790glc.init();
    if (rc != 0) {
    Serial.println("BH1790 initialize failed");
    } else {
    Serial.println("LEDON Data, LEDOFF Data");
    MsTimer2::stop();
    MsTimer2::set(31, timer_isr); // 32Hz timer
    MsTimer2::start();
    }
    }

    void loop() {
    byte rc;
    unsigned short val[2];

    if (timer_flg) {
    rc = bh1790glc.get_val(val);
    if (rc == 0) {
    sprintf(str, "%d, %d\n", val[1], val[0]);
    Serial.print(str);
    }
    timer_flg = false;
    }

    }

    void timer_isr(void) {
    timer_flg = true;
    }



  • In reply to Okamiya Yuuki:

    i still see this error. during project import, i selected the GP peach template

    The Compilation Is Complete

    make: *** No rule to make target `gr_common/core/main.o', needed by `gr_build/peach_sketch.elf'. Stop.
  • In reply to Okamiya Yuuki:

    can you details the step to import your file? i fail to run it
  • In reply to weiwei2:

    Hi,

    There are two basical project templates:
    one is "GR-PEACH_mbed_style_Vx.xx.zip" that enables to make a code like mbed Compiler,
    the other one is "GR-PEACH_Sketch_Vx.xx.zip" that enables to make a code like Arduino sketch.

    So you need to create a new project using "GR-PEACH_Sketch_Vx.xx.zip".
    Next import BH1790GLC.zip in project root, then copy example to "gr_sketch.cpp".