Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Data is not transferring to Data register of SPI in MG32F157VCT6

@ADEngineer

New Member
I am using MG32F157VCT6 for SPI connectivity but the MCU is not transferring data to the SPIx->DR and vice-versa for receiving data. This issue is happening even in the example code given in the library.
 

Attachments

I can't help you with your specific processor, but if the code is correct and the connections are correct, then it will almost certainly work.

The most likely reason is you're doing something wrong somewhere, the issue is finding out what and where.

Are you using a commercial development board?, if so there 'should' be ready-made working examples you can run on the board 'as is', then try and alter them (bit by bit) to try and get it to do exactly what you want. Potentially, you will reach a point where it stops working, and that's likely to be where the error is.

The problem with any micro-controller issue is deciding if the issue is hardware, software, or both - which is where using a proven development board, and working examples, can help.

I must admit, I've often had issues with SPI, for a relatively simple interface it causes lots of problems.
 
This is mcu is commercial and I have already tested its example code on SPI but still the issue stays same because the SCK is getting generated internally and so data is not getting transferred to the data register. I have also performed trace run. This is the example project of SPI on mg32f157.

The mcu is 90% as same as STM32F105VCT6 peripheral to peripheral and register to register except for some there is change in addresses.
 

Attachments

Are you trying to use the MCU as a slave device? Your description is not clear on that.
If that is the case, it might explain why MG32F157VCT6 is not generating SCLK. SPI is not a request response kind of exchange. Whenever data is sent, data is also received on the same clock pulses. The received data is whatever the peripheral device has available when a transmission begins. Often this is "NULL" or meaningless data, and it is discarded.

The way to debug this is to have the MG32F157VCT6 disconnected from ALL of the peripheral devices, put it in a loop sending data, and see if the SCLK pulses appear. If they don't then you have some investigation to do.
 
If that is the case, it might explain why MG32F157VCT6 is not generating SCLK. SPI is not a request response kind of exchange. Whenever data is sent, data is also received on the same clock pulses. The received data is whatever the peripheral device has available when a transmission begins. Often this is "NULL" or meaningless data, and it is discarded.

The way to debug this is to have the MG32F157VCT6 disconnected from ALL of the peripheral devices, put it in a loop sending data, and see if the SCLK pulses appear. If they don't then you have some investigation to do.
I have already done that. This is happening with all other mg32f157vct6. All the procedure is as per the documentation still no sck. Although the same procedure when executed on STM32 BluePill it works.
 
Last edited:
Is the pin configuration for the pin SCLK is used for correct. With multi-function pins on many processors this can be a convoluted process to decode and implement.
 

Latest threads

Back
Top