Closed planestoner closed 1 year ago
thanks @planestoner, I like your effort,
can you check what HAL_SPI_Receive() returns?
like:
HAL_StatusTypeDef errcode;
errcode = HAL_SPI_Receive(&hspi1, data, 2, 100);
Data from logic analyser seems to be fine in both cases:
that hal_delay fix is quite strange anyway..
Thanks @polihedron for the reply. I've tried a few things and long story short I only get a good temp reading is the the inclusion of the hal_delay.
With errcode = HAL_SPI_Receive(&hspi1, data, 1, 100);
and without delay I get these:
Setting HAL_SPI_Receive(&hspi1, data, 1, 100);
seems to pull CS low for too short a time unless I introduce the delay and I get this (errcode returns HAL_OK):
@planestoner maybe spi is not ready then?
this code is a bit messy, and since my oven is working I don't have time and motivation for general refactoring. so my another idea is to use library like: https://github.com/ipa64/MAX6675-STM32-library-using-HAL
or check this:
while ((HAL_SPI_GetState(&hspi1) != HAL_SPI_STATE_READY));
put it before spi read.
I'm in the same boat regarding time and since my device works with the included delay I'm happy for you to close the issue.
If the code is the issue maybe we or someone will be able to spot it and re-open this issue. In the mean time the work around is to add in the delay.
@planestoner @polihedron Hi Guys, i havent seen the issue here, i managed to buy all the parts and assembled all the parts and noticed that the temperature reading is stable 0.0 Degrees. Can you please help me? Can i use your bin file with the delay to fix my issue?
Hi there @Gokhanto
@polihedron Thanks for the quick reply. I started to open the project file but the main.c document looked like a chineese document with weird sysmbols, not much to read. But i managed to open the main.c file by it self and added the delay, but im getting an error "Failed to connect to device., Failed to start GDB server."
@Gokhanto I'm sorry I can't help you with this, please read or watch some tutorials on internet how to flash stm32 bluepill with st-link.
I've checked and sadly I don't have any of those files any more. Sorry
@planestoner @polihedron Just for your information, i found out that the stm32, i had were a clone, so i ordered a new one and it solved all the problems, everything works.
'temp' & t0 returns/displays zero (0.0) on Nextion display and serial logging when flashing release and debug Reflow_Oven_STM32.bin
Multiple resolutions attempted to no avail including:
When testing MAX6675 module with ESP32 it shows this:
When testing MAX6675 module with STM32F103 with Reflow_Oven_STM32.bin it shows this:
When debugging Reflow_Oven_STM32.bin with ST-Link V2 'temp' reads 0.0 when setting breakpoint on main.c line 793
However, 'temp' reads correctly when setting breakpoint on main.c after line 779 (after HAL_SPI_Receive)
When adding
HAL_Delay(1);
the code runs fine (with CS being pulled low horribly long), although, this is merely a work around and not a proper fix. I tried the delay in a few placed but this seems the best location for the workaround.I considered raising a PR with the added delay but STM32 documentation doesn't include it nor does the MAX6675 datasheet. I'm not entirely sure this is an issue with the code, however, raising an issue as there are no doubt better minds than mine out there with a lot more experience. Also raising this for those in the future that run into this problem. Suggested possible causes: