Problem with ArdOS and an I2C lcd display

I'm experiencing problems with the RTOS ArdOS combined with the following library for an I2C lcd display https://codeload.github.com/vanluynm/LiquidCrystal_I2C/zip/master.
The library works fine when used without ArdOS, but if the library is used within a task in ArdOS, it crashes the Arduino.. I hope someone can help.

The problem occurs when I'm using the library method, 'setCursor', which like all the other methods use the Wire library to start a transmission and write bytes to the address of the lcd. So I suspect the wire library to be the main problem, do anyone have an idea how to fix it?

Thanks in advance!

do anyone have an idea how to fix it?

Do anyone have any code that they want to share?

If the I2C/Wire library doesn't use interrupts (can't remember) then you could try
diasbling interrupts around LiquidCrystal_I2C calls?

If the I2C/Wire library doesn't use interrupts (can't remember)

The Wire library is all about interrupts.

PaulS:

do anyone have an idea how to fix it?

Do anyone have any code that they want to share?

haha yes ofc. ArdOS can be downloded here: https://bitbucket.org/ctank/ardos/downloads

Here's the method within the LCD display, which crashes the Arduino

void LiquidCrystal_I2C::setCursor(uint8_t col, uint8_t row){
	int row_offsets[] = { 0x00, 0x40, 0x14, 0x54 };
	if ( row > _numlines ) {
		row = _numlines-1;    // we count rows starting w/0
	}
	command(LCD_SETDDRAMADDR | (col + row_offsets[row]));
}

Furtheremore command looks like this:

inline void LiquidCrystal_I2C::command(uint8_t value) {
	send(value, 0);
}

The send method looks like this:

void LiquidCrystal_I2C::send(uint8_t value, uint8_t mode) {
	uint8_t highnib = value & 0xF0;
	uint8_t lownib = value << 4;
	write4bits((highnib)|mode);
	write4bits((lownib)|mode);
}

write4bits method, note that pulseEnable also call the next method. Therefore it is not showed..

void LiquidCrystal_I2C::write4bits(uint8_t value) {
	expanderWrite(value);
	pulseEnable(value);
}

ExpanderWrite uses Wire.h to write to the LCD display.

void LiquidCrystal_I2C::expanderWrite(uint8_t _data){                                        
	Wire.beginTransmission(_Addr);
	Wire.write((int)(_data) | _backlightval);
	Wire.endTransmission();   
}

This is the code for implementing af task in ArdOS

#include <kernel.h>
#include <mutex.h>
#include <queue.h>
#include <sema.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>

LiquidCrystal_I2C lcd(0x27,20,4); //Where 0,27 is the address of the lcd, 20 is characters and 4 is number of lines


void task1(void *p)
{
  while(1)
  {
    lcd.setCursor(2,2);
    lcd.printstr("This is a test");
    
    OSSleep(500); //Sleeps the task for 500 miliseconds
    lcd.clear();
    OSSleep(500);

  }
}


void setup()
{
  lcd.init();
  lcd.clear();
  lcd.backlight();

  OSInit(1);
  OSCreateTask(0, task1, NULL); //Where 0 is the priority
  OSRun();
}

void loop()
{
  
}

Here's the method within the LCD display, which crashes the Arduino

How are you determining that the Arduino has "crashed"?

Any progress on this topic ?