RAK5010 Interrupt

Hi. I’m trying to use RAK interrupt example. I compiled/burned successfully the firmware to the RAK5010.

Debugging with J-Link RTT Viewer, the interrupt on Pin 16 NOT WORKING. Same issue I have in Espruino with this interrupt. (lis3dh acceleration sensor interrupt)

What I’m doing wrong ?

Thanks

Hi, do you modify any code? Or just use the example? The example we test is ok. So if you just run it without any modification, twist it to trigger the interrupt. If you modify any, post the code, we will check.

Hi nero. Thanks for your quick reply.

My user_app.c lool like this:

#include “rui.h”
#include “lis3dh.h”
#include “opt3001.h”
#include “shtc3.h”
#include “lps22hb.h”

RUI_I2C_ST st = {0};

void sensor_on(void)
{

st.PIN_SDA = 14;
st.PIN_SCL = 13;
st.FREQUENCY = RUI_I2C_FREQ_400K;
rui_i2c_init(&st);

//lis3dh init
lis3dh_init();
//opt3001 init
opt3001_init();
//shtc3 init
SHTC3_Wakeup();
//lps22hb init 1 wake up
lps22hb_mode(1);

}

void sensor_off(void)
{
lis3dh_sleep_init();
sensorOpt3001Enable(0);
SHTC3_Sleep();
lps22hb_mode(0);
}

RUI_GPIO_ST lis3dh_st;
uint8_t wake_flag = 0;

void test_lis3dh()
{
RUI_LOG_PRINTF(“enter!!!”);
if (wake_flag == 0)
{
RUI_LOG_PRINTF(“sleep!!!”);
rui_device_sleep(1);
wake_flag = 1;
}
else
{
RUI_LOG_PRINTF(“wake!!!”);
rui_device_sleep(0);
wake_flag = 0;
}

}

void main(void)
{
//system init
lis3dh_st.pin_num = 16;
lis3dh_st.dir = RUI_GPIO_PIN_DIR_INPUT;
lis3dh_st.pull = RUI_GPIO_PIN_PULLDOWN;
rui_gpio_interrupt(true, lis3dh_st, RUI_GPIO_EDGE_RAISE, RUI_GPIO_IRQ_HIGH_PRIORITY,test_lis3dh);

rui_sensor_register_callback(sensor_on,sensor_off);

rui_init();
while(1)
{
    //do your work here, then call rui_device_sleep(1) to sleep

    //here run system work and do not modify
    rui_running();
}

}

I modify nothing on the original code…

Interesting, even using Espruino I had issue using this interrupt. I’m beginner using RUI, I’m at testing the RUI platform.

Zoltan

I see. The interrupt threshold value in lis3dh.c is 2 and you need twist the board which trigger the interrupt. And I think you may be stuck in the communication with BG96. From you log, the AT+ QGPS = -1 means it runs abnormally. Please remove the Jlink, judge the state exchange via the led. After it starts ok, twist the board, you will find led off which means sleep. And then twist, it will on means wake up. But remember not twist continually, in view of the reaction of board.

Thanks. Followed your instructions, I had success once but I can’t reproduce the event again. At next attempts the device goes to sleep but don’t weakup, the led remains off…

The bg96/gps status should not influence this interrupt. The sensors are drived by NRF52840, I think…

Zoltan

The bg96 will not affect it. But the sleep and wake up include at communication with the BG96. If it is stuck, it will not work. You can change the code by the green LED on board, just test interrupt and ignore BG96:

RUI_GPIO_ST led;
uint8_t state = 0;

void test_lis3dh()
{
RUI_LOG_PRINTF(“enter!!!”);
if (wake_flag == 0)
{
state = 1;
rui_gpio_rw(RUI_IF_WRITE,&led,&state);
wake_flag = 1;
}
else
{
state = 0;
rui_gpio_rw(RUI_IF_WRITE,&led,&state);
wake_flag = 0;
}

}

void main(void)
{
//system init
lis3dh_st.pin_num = 16;
lis3dh_st.dir = RUI_GPIO_PIN_DIR_INPUT;
lis3dh_st.pull = RUI_GPIO_PIN_PULLDOWN;
rui_gpio_interrupt(true, lis3dh_st, RUI_GPIO_EDGE_RAISE, RUI_GPIO_IRQ_HIGH_PRIORITY,test_lis3dh);

led.pin_num = 12;
led.dir = RUI_GPIO_PIN_DIR_OUTPUT;
led.pull = RUI_GPIO_PIN_NOPULL;
rui_gpio_init(&led);

rui_sensor_register_callback(sensor_on,sensor_off);

rui_init();
while(1)
{
    //do your work here, then call rui_device_sleep(1) to sleep

    //here run system work and do not modify
    rui_running();
}

}

Green LED goes ON/OFF if I shake the device. I will check the BG96 why give me error…

Thanks for your quick help
Zoltan

OK. Pay attention to the Jlink. We find the piratic Jlink will make BG96 lose efficacy. So if I advise you use USB to communicate, though the log information is not enough

Hi nero (Du)
Q. If I don’t use Jlink, how can I debug my code ? I’m little bit confused about the debugging methods of my custom firmware. I try to use RUI compiler and nothing else (Espruino/Arduino/…) because RUI it’s native and universal for many RAK products what I want to test/use in the near future. I use Termite with USB connection now and have no debug info…

Zoltan

The problem is just about JLINK. The VCC on 5010 is for input from JLINK. Genuine JLINK will work OK. But pirated JLINK will make BG96 work abnormally. There is no any problem with genuine JLINK, that’s my suggestion.

Dear friend, you suggesting to buy one ~800USD device to use with your ~80USD device ? It’s crazy !
Any cheaper solution do you have?

Thanks
Zoltan

[email protected]

That’s just a suggestion. However, we have a good solution for user. Print log via USB. You can refer to my code below. I start a timer to print log per 1s.:

#include “rui.h”
#include “lis3dh.h”
#include “opt3001.h”
#include “shtc3.h”
#include “lps22hb.h”
#include <stdarg.h>

extern void usbd_send(uint8_t *pdata, uint16_t len);

void usb_log_printf(const char *fmt, …)
{
char print_buf[512];
va_list aptr;
int ret;

va_start (aptr, fmt);
ret = vsprintf (print_buf, fmt, aptr);
va_end (aptr);

usbd_send(print_buf, strlen(print_buf));

}

RUI_I2C_ST st = {0};

void sensor_on(void)
{

st.PIN_SDA = 14;
st.PIN_SCL = 13;
st.FREQUENCY = RUI_I2C_FREQ_400K;
rui_i2c_init(&st);

//lis3dh init
lis3dh_init();
//opt3001 init
opt3001_init();
//shtc3 init
SHTC3_Wakeup();
//lps22hb init 1 wake up
lps22hb_mode(1);

}

void sensor_off(void)
{
lis3dh_sleep_init();
sensorOpt3001Enable(0);
SHTC3_Sleep();
lps22hb_mode(0);
}

//timer task to print log
RUI_TIMER_ST rui_timer;
uint8_t timer_flag=0;
void timer_callback(void)
{
timer_flag = 1;
}

void timer_init()
{
rui_timer.timer_mode = RUI_TIMER_MODE_REPEATED;
rui_timer_init(&rui_timer, timer_callback);
rui_timer_setvalue(&rui_timer, 1000);
rui_timer_start(&rui_timer);
}

void main(void)
{
//system init
rui_sensor_register_callback(sensor_on,sensor_off);
rui_init();
timer_init();
while(1)
{
//do your work here, then call rui_device_sleep(1) to sleep
//here run system work and do not modify
if (timer_flag == 1)
{
usb_log_printf(“This is from USB!!”);
//usb_log_printf(“This is %d”,a);
//usb_log_printf(“This is %f”,b);
timer_flag = 0;
}
rui_running();

}

}

Very Thanks. I’m traveling. Soon as possible I will try your code.

Thanks again
Zoltan

Hi
I made the modifications what you Sir posted. My issue is with the RUI online compiler !
Witch of them are good to use ? I try both, but no success …

Zoltan

The code is based on the user_app.c and can be used with online compiler. You can just copy the usb print part to your code.

Thanks Dear friend. But I can’t use the RUI Online compiler to check your code !
I miss something ?

Zoltan

I want to be one not smart user. I buy/instructions/ready to sell

Can your company offer this to me ?

Hi, in fact, only copy below to your code. And call usb_log_printf in place what you want to print. I’m not clear the “check” you mention.
#include <stdarg.h>

extern void usbd_send(uint8_t *pdata, uint16_t len);

void usb_log_printf(const char *fmt, …)
{
char print_buf[512];
va_list aptr;
int ret;

va_start (aptr, fmt);
ret = vsprintf (print_buf, fmt, aptr);
va_end (aptr);

usbd_send(print_buf, strlen(print_buf));

}

"I want to be one not smart user. I buy/instructions/ready to sell

Can your company offer this to me ?"

I am still confused. So what goals do you want? You want to build your own application? Or you want us help you build it? Or any other thing? If you are not good at code, tell us your idea. I will help you realize it.

Hi Sir.

None of the online RUI compiler NOT WORKING to me ! What happening ?

I can wait to fix them, no worries, but My suggestion to your company to advice your clients before /after doing some site updating work. I think…

Zoltan

To answer to your questions, I have to know more about this device. What it’s your h work price ?

Are you people can answers to this RUI compiler malfunction?

Hi @magdoz59 The RUI compiler is up and running for EU and Asia(I can not test other locations :slight_smile: ), so it can be a local problem at your location as the RUI is hosted on a cloud.

And please make sure that you use the 2.0 RUI compiler here https://build.rakwireless.com/