Wonky printf in LCD code.

Discuss how to use the features of Atollic TrueSTUDIO, including the editor, assembler, C/C++ compiler, linker, debugger, static code analysis and team collaboration tools.

Moderators: Markus Girdland, Mattias Norlander

vanluynm
Posts: 6
Joined: Sat Jan 26, 2019 6:00 pm

Wonky printf in LCD code.

Postby vanluynm » Sat Jan 26, 2019 6:16 pm

Hi,

Porting I2C interfaced LCD code, and can't get printf() to sensibly engage with a working _write() implementation. Mostly no output, infrequently seen filling LCD display with repeats of output expected.

Got printf() to send to UART via HAL calls in _write() before, but no clue why LCD code attempt fails?

Code: Select all

// In LCD_I2C.c
// Both I/O functions tried, and seemingly working.

int __io_putchar(int ch)
{
  lcd_i2c_write((uint8_t)ch);

  return(ch);
}

int _write(int file, char *ptr, int len)
{
  int chars_left = len;

  while(chars_left--) __io_putchar(*ptr++);

  return(len);
}


Sorry, new to CubeMX/ Atollic, so not sure what else to post?

M.

vanluynm
Posts: 6
Joined: Sat Jan 26, 2019 6:00 pm

Re: Wonky printf in LCD code.

Postby vanluynm » Sun Jan 27, 2019 12:27 pm

No clues, requisite heap, stack sizes, how to adjust? Anything else I need to consider?

What should I be posting for assessment?

vanluynm
Posts: 6
Joined: Sat Jan 26, 2019 6:00 pm

Re: Wonky printf in LCD code.

Postby vanluynm » Sun Jan 27, 2019 2:08 pm

Okay, tried doubling heap and stack sizes, by altering linker script, but that's not it.

What else should I check?

vanluynm
Posts: 6
Joined: Sat Jan 26, 2019 6:00 pm

Re: Wonky printf in LCD code.

Postby vanluynm » Sun Jan 27, 2019 2:27 pm

Okay, so I added a tiny_printf.c implementation to the project and it works.

Does that afford me any clues as to why then it hadn't worked previously?

vanluynm
Posts: 6
Joined: Sat Jan 26, 2019 6:00 pm

Re: Wonky printf in LCD code.

Postby vanluynm » Tue Jan 29, 2019 10:35 pm

For anyone that might be interested in the I2C LCD code library, I've posted a link:

https://www.duenna.science/stm32/

Bookmark and come visit https://www.duenna.science/ for further developments.

vanluynm
Posts: 6
Joined: Sat Jan 26, 2019 6:00 pm

Re: Wonky printf in LCD code.

Postby vanluynm » Fri Feb 01, 2019 8:53 pm

Someone might be interested in the 4-bit port mapped version of the previous i2c LCD code:

LCD_4Bit_in_C_for_STM32CubeMX_Atollic_TrueSTUDIO to run on STM32F103C8 Blue Pill.

Find it under https://www.duenna.science/stm32/ at https://www.duenna.science/

:)


Return to “Atollic TrueSTUDIO tool discussions”

Who is online

Users browsing this forum: No registered users and 5 guests