Skip to main content
20 events
when toggle format what by license comment
Jun 20, 2023 at 16:32 comment added Rodo @Justme: I always try to use the basic functions as a way to see that my setup is working properly. Then I venture into more advance options.
Jun 19, 2023 at 20:37 comment added Justme The HAL uses 8-bit notation so it should be given 0x16 (or 0x17) as the adress, as the HAL will automatically clear or set the LSB for read and write operations so 0x16 or 0x17 will be on bus like the chip datasheet says. So the address can't be (0x16 << 1).
Jun 19, 2023 at 20:24 comment added Jim Fischer @Ali, try this: define variable dev_address's value like this: uint8_t dev_address = (0x16 << 1). Do not manually "bit bang" the read/write bit (i.e., 0x16|0x01) when specifying the IC's device address; the HAL library sets or clears the read/write bit as needed.
Jun 19, 2023 at 18:44 comment added Justme @Rodo actually the Mem_Read and Write are the best functions here, because otherwise you would need to build their functionality anyway to access the chip registers. There is no reason to use the "simpler" functions you suggest, they would not work any better if the chip does not respond with ACK.
Jun 19, 2023 at 17:20 comment added Rodo @justme: Yeap I made an error. The rest of my comment stands though. Thanks for pointing that out.
Jun 18, 2023 at 19:50 comment added Justme @Ali As per your debugging, the error code is AF_FLAG. The chip does not acknowledge the address. Now we can't say why that happens. Maybe your wires are crossed, disconnected, or other hardware issue
Jun 18, 2023 at 19:43 comment added Justme @Rodo You are incorrect. That function has nothing to do with DMA. Do verify it from the link you posted yourself.
Jun 18, 2023 at 17:35 comment added SamGibson @Ali - Hi, You wrote an "answer" but it was actually more info, not a solution, so it has been added to your question as an edit (i.e. an update) instead. || Since you asked the question, unless you are writing the full & final answer to your own question (i.e. unless you don't need further help & you solved the problem yourself using a different solution than any other answer) please don't use the box labeled "Your Answer" below. Instead, to add more info / clarification, please edit the question. Or comment to respond to an answer. || Please see the tour & help center. Thanks
Jun 18, 2023 at 17:27 history edited SamGibson CC BY-SA 4.0
appended answer 670931 as supplemental
Jun 18, 2023 at 17:26 comment added Rodo The function you are using "HAL_I2C_Mem_Read(...)" uses DMA. Did u setup DMA? Why don't you use the simpler function(s) HAL_I2C_Master_Receive(...) or HAL_I2C_Master_Transmit(...) ? You can find more info on the "Description of STM32F1 HAL and low-layer drivers" (st.com/resource/en/user_manual/…)
Jun 18, 2023 at 6:46 answer added Jim Fischer timeline score: -1
Jun 17, 2023 at 17:39 comment added Justme @Ali if you get an error, the next step you need to take is to check which error you got. Then you know why there is an error. If your next question is how you check it, you do have HAL source code in your project already which you can debug and you seem to have the HAL manual too as you know what functions the HAL provides.
Jun 17, 2023 at 16:21 comment added Ali #Justme I get HAL_ERROR instead of HAL_OK. I do not know why I get HAL_ERROR and do not know what I missed. If you see the problem please let me know
Jun 17, 2023 at 16:13 comment added Ali I should get HAL_OK but I get HAL_ERROR. I forgot to add HAL_OK at the end of the code
Jun 17, 2023 at 16:04 comment added SamGibson Ali - Hi, I have improved the code formatting to match what you wrote in your duplicate (now deleted) question. Please read the tour & help center to see the main site rules and to see how Stack Exchange differs from typical forums e.g. on Stack Exchange, questions can be edited to improve them e.g. to clarify, add new info, make them easier to read etc. (although changes should not be made which invalidate existing answers).
Jun 17, 2023 at 16:01 history edited JYelton CC BY-SA 4.0
edited body; edited title
Jun 17, 2023 at 15:56 history edited SamGibson CC BY-SA 4.0
Improve layout and copied improved code formatting (using code fences) from the duplicate question asked by the OP.
Jun 17, 2023 at 14:58 comment added Justme If you don't get HAL_OK, what error you get then? This defines how to proceed.
S Jun 17, 2023 at 14:55 review First questions
Jun 17, 2023 at 20:16
S Jun 17, 2023 at 14:55 history asked Ali CC BY-SA 4.0