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.

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);
	}
}
 
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.

Latest threads

New Articles From Microcontroller Tips

Back
Top