Mity Eltu
Member
OK. I have just spent the better part of the day banging on this project and have found something that is either really irritating and incredibly frustrating or is a serious problem for oshonsoft, or I may just be an idiot and need help.
This is the story...
18F4520, 8MHz internal osc. LCD with 4 bit low on portd.
I needed to be able to sample a thermocouple that will be using SPI to communicate with the PIC and then store the data on an SD card for later analysis on a PC. No problem.
I was able to get the thermocouple working while displaying the current temp on the LCD within a few minutes. I am using the MAX6675 which incorporates a 12 bit A/D and cold junction compensation - kill 2 birds with one stone, right?
Next came the SD card. I was able to get the SD card working great a few weeks ago. but then I added the SAME CODE from the working project into this one with the thermocouple. No dice. I checked, rechecked and double rechecked about a hundred times today. The SD card would not even be recognized. I am using a considerable portion of the code found on the oshosoft website for the SD Card Example (https://www.oshonsoft.com/sdcard.php). Like I said, it worked great when it was by itself. Logged data and was able to get the file off the card with a pc. No problem.
So I decided to do a little side by side comparison of the code. The ONLY difference between the 2 was the SPI setup in the code with the thermocouple. I HAVE to have the SPI working to get data from the thermocouple. Apparently, the sdcardinit command does all this for the sd card. As soon as I removed the lines for SSPCON1 and SSTSTAT, the SD card started working.
I have not yet had the time (as I have spent the ENTIRE day on this one part) to see if this has made it impossible for the thermocouple to communicate - though I suspect it has.
This is a serious problem as I need the communications for both in the same project and on the same chip. Has anyone come across this before? Is there a fix? Am I just an idiot and the SPI communications will work just fine wihtout the SSPCON1 and SSPSTAT registers being set?
What say you all?
This is the story...
18F4520, 8MHz internal osc. LCD with 4 bit low on portd.
I needed to be able to sample a thermocouple that will be using SPI to communicate with the PIC and then store the data on an SD card for later analysis on a PC. No problem.
I was able to get the thermocouple working while displaying the current temp on the LCD within a few minutes. I am using the MAX6675 which incorporates a 12 bit A/D and cold junction compensation - kill 2 birds with one stone, right?
Next came the SD card. I was able to get the SD card working great a few weeks ago. but then I added the SAME CODE from the working project into this one with the thermocouple. No dice. I checked, rechecked and double rechecked about a hundred times today. The SD card would not even be recognized. I am using a considerable portion of the code found on the oshosoft website for the SD Card Example (https://www.oshonsoft.com/sdcard.php). Like I said, it worked great when it was by itself. Logged data and was able to get the file off the card with a pc. No problem.
So I decided to do a little side by side comparison of the code. The ONLY difference between the 2 was the SPI setup in the code with the thermocouple. I HAVE to have the SPI working to get data from the thermocouple. Apparently, the sdcardinit command does all this for the sd card. As soon as I removed the lines for SSPCON1 and SSTSTAT, the SD card started working.
I have not yet had the time (as I have spent the ENTIRE day on this one part) to see if this has made it impossible for the thermocouple to communicate - though I suspect it has.
This is a serious problem as I need the communications for both in the same project and on the same chip. Has anyone come across this before? Is there a fix? Am I just an idiot and the SPI communications will work just fine wihtout the SSPCON1 and SSPSTAT registers being set?
What say you all?