Hi I had made a board with LPC1768 and wrote code for UART, ADC, SD_File, Ethernet, CAN etc. All working I ordered for new boards with solder mask, with no difference on chip connections. Again almost everything such as UART, ADC, Ethernet and ... are working, just SD File is not working
I looked at SCK0 using an oscilloscope in the first board (Even with SD out) and I could see obvious clock pulses Then I looked at SCK0 of the second board, I was just having SCK0 driven low for a short time and then high state again
Could anyone suggest me how I can figure out the problem?
To check SPI, I wrote another simple code, I could see pulses on SCK0, but when I use finit(NULL), it's not working
Thank you in advance for your help
Step one when you have issues with new electronics is to make use of the magic wonders that many microcontrollers allows us - their ability to wiggle on almost all of their pins.
So make use of normal GPIO modes to validate all pins related to the memory card interface. Can your output lines correctly drive all signals low and high and generate distinct signal state changes? Can all input signals be correctly sampled by the processor when you hold the signals high or low?
And then also check if the PCB has supply voltages on all points where it is expected to.
If all signals are ok according to the above, then the PCB is good - the only remaining issue then would be that you either have a completely wrong crystal frequency making you run the processor as a different frequency than you think. Or maybe that the memory card holder is bad and doesn't make proper contact with the memory card.
Another thing to consider is if all capacitors on supply lines are correctly mounted so you have stable supply voltages to the processor and to the memory card.
If you have pull-up, pull-down or series resistors on the signals, then take a closer look at their values so they haven't been incorrectly mounted.
Thank you for your excellent comments Your ideas are right, but I have tried most of them already
I had 2 sample boards, both with working SD interface then I assembled 4 other boards, none of them are working
I thought maybe SPI module of the chip cannot work on these pins, but when I programmed another sample SPI project and I could see SCK pulses, I forgot about this idea
I have jlink to debug. Although I am sure my problem is in hardware, because the code has been tested already, but I'd like to figure out WHAT Happens? and WHERE exactly the chip cannot continue to be able to discover why?!
But finit is not a function that I can step in, and see where it stops and figure out why SCK is not generating pulses while it can generate pulse for other SPI (not SD related) code
Solved. The problem was that P4.29 should be pulled down when using flash_fs library
I had removed that resistor because I believed RXD3 should be pulled up