Hi Tech C software SPI not working

Status
Not open for further replies.

john blue

Member
It seems that my software SPI in Hi Tech C is not working. Can anyone please help? Not sure whether i have missed out something. Thanks in advance.

Code:
#include <htc.h>
#include "sw_spi.h"
#include "delay.h"

void main(void){
	// configure software SPI
		OpenSWSPI();
		DelayMs(5);
		ClearCSSWSPI(); //clear CS pin
		WriteSWSPI(0x40);
			WriteSWSPI(0x00);
			WriteSWSPI(0x00);
		SetCSSWSPI();
		
		for(;;)
		{	
		//HIGHLIGHT MCP23S08
		ClearCSSWSPI();
		WriteSWSPI(0x40);
		WriteSWSPI(0x09);
		WriteSWSPI(0x01);
		SetCSSWSPI();
		DelayMs(40);
		DelayMs(40);
		DelayMs(40);
	}
}
 
If this is a software SPI solution, where are the pins scl, sda, sdi and cs defined? who's SPI library are you using? Lastly.. where did you get it?
 
The pins are defined in sw_spi.h. The solution is from Hi Tech C in version 9.66. Attached are the files.
 

Attachments

  • SW_SPI.zip
    14.2 KB · Views: 293
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…