J john blue Member Aug 18, 2011 #1 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); } }
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); } }
Ian Rogers User Extraordinaire Forum Supporter Most Helpful Member Aug 18, 2011 #2 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?
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?
J john blue Member Aug 18, 2011 #3 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
The pins are defined in sw_spi.h. The solution is from Hi Tech C in version 9.66. Attached are the files.