- Make sure you have enough stack! If you didn't set it at project generation time, fix it in your .ld file (and be sure to fix it in the CubeMX project too in case you regenerate.
- Also, create a dummy project with the IDE and NOT CubeMX. Steal the syscalls.c file from that project and put it in your project.
- Obviously, you need to set up the UART in CubeMX.
- Add this:
int __io_putchar(int ch)
{
uint8_t ch8=ch;
HAL_UART_Transmit(&huart1,(uint8_t *)&ch8,1,HAL_MAX_DELAY);
return ch;
}
int __io_getchar()
{
uint8_t ch8;
HAL_UART_Receive(&huart1,&ch8,1,HAL_MAX_DELAY);
return 0;
}
Done! Mysterious crashes means your stack is too small or you have left the boot jumpers set funny and SP isn't set to what you think it is.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.
I hate printf....
Are you sure? yes | no
Oops. Obviously __io_getchar needs to return ch8 not 0. Sorry!
Are you sure? yes | no