2025-04-24 8:40 AM - last edited on 2025-04-24 8:58 AM by TDK
I AM TRYING TO CONTROL WITH CLRC SPI. MY PROJECT IS WRITTEN WITH LL. I CANNOT ADAPTE THIS FUNCTION. CAN YOU PLEASE HELP ME?
2025-04-24 8:42 AM
I SET IT LIKE THIS BUT IT DID NOT WORK
2025-04-24 9:00 AM
Please don't use all caps, it is distracting.
Is the SPI initialized? Show this.
Show the state of the SPI registers when it is not working.
2025-04-24 9:07 AM
yes spi started there is no problem, attached is the image
2025-04-24 9:08 AM
I think the data order is mixed up, I am doing the same as the example in github.
2025-04-24 10:23 AM
What is "not working" about it? What do you expect to happen? What happens instead? Do you know how to debug the code and step through, examine registers, etc?
2025-04-25 12:09 AM
There are 2 functions in STM32CUBE WITH KEIL LL AND HAL. Does this do the same thing? The code is not working. Is it because of bit shift? I am not sure.
2025-04-25 8:00 AM
I asked 4 questions and you answered 0 of them. I'm not going to be able to assist without any engagement on your end.
The HAL code is open source, you can open it up and inspect what it does. It's more complicated than your SPI2_ByteSend function.
2025-04-29 5:40 AM - edited 2025-04-29 6:55 AM
Duplicate - merged.
Please don't start multiple threads on the same topic.
Hello dear friends,
I have an STM32L433 project written using the Low Layer (LL) library, and I’m trying to integrate the CLRC663 NFC reader into it. However, I’ve been struggling to convert the HAL_SPI_TransmitReceive function into its equivalent using only LL functions. I cannot use the HAL library at all, since there are other slave devices in the system and compatibility issues arise.
I’ve searched the internet and found some LL-based SPI examples, some of which I’ve attached screenshots of, but unfortunately, none of them worked. What I need is a fully functional equivalent of HAL_SPI_TransmitReceive written using only LL. Where can I find such an implementation?
Any help would be greatly appreciated.
WORKING CODE:
void mfrc630_SPI_transfer(const uint8_t* tx, uint8_t* rx, uint16_t len)
{
switch(HAL_SPI_TransmitReceive(&hspi2, tx, rx, len, 1000))
{
case HAL_OK:
// Communication is completed, dont do anything.
break;
case HAL_TIMEOUT:
printf("Timeout\n");
case HAL_ERROR:
printf("Some error\n");
Error_Handler();
break;
default:
break;
}
}
THE CODE THAT DOESN'T WORK AND I TRY TO WRITE WITH LL:
uint8_t SPI2_ByteSend (uint8_t val)
{
LL_SPI_TransmitData8(SPI2, val);
while (LL_SPI_IsActiveFlag_BSY(SPI2));
return(LL_SPI_ReceiveData8(SPI2));
}
void mfrc630_SPI_transfer(const uint8_t* tx, uint8_t* rx, uint16_t len)
{
mfrc630_SPI_select();
for (uint16_t i = 0; i < len; i++) {
// SPI2_ByteSend her gönderilen byte'in karsiliginda dönen byte'i döner
rx[i] = SPI2_ByteSend(tx[i]);
}
mfrc630_SPI_unselect();
}
PLEASE HELP!
2025-04-29 6:21 AM
Please see How to insert source code.
@YBAYR.1 wrote:THE CODE THAT DOESN'T WORK
Saying "doesn't work" tells us next to nothing.
See: How to write your question to maximize your chances to find a solution.
@YBAYR.1 wrote:WORKING CODE:
As @TDK already said, step through that code and understand what it's doing.
Then replicate that in your LL code.
@YBAYR.1 wrote:I cannot use the HAL library at all, since there are other slave devices in the system and compatibility issues arise
What "compatibility issues", exactly ?
HAL shouldn't impose any restrictions beyond the limitations of the STM32 hardware.
Besides, you can use both LL and HAL together.