12f1840 spi inop

Moderator: Benj

brandonb
Posts: 438
Joined: Mon Aug 29, 2011 12:26 am
Location: arizona
Has thanked: 175 times
Been thanked: 173 times
Contact:

12f1840 spi inop

Postby brandonb » Tue Nov 26, 2013 9:21 am

is there anything special to do on this chip to get spi working? i wrote spi code for it and can't get it working either, i get one pulse on power on and thats it, did internet search and erratica search but shows nothing... can someone look into this for me have plans for it if resolved
forgot to say i also tried this with alternate pins

brandonb
Posts: 438
Joined: Mon Aug 29, 2011 12:26 am
Location: arizona
Has thanked: 175 times
Been thanked: 173 times
Contact:

Re: 12f1840 spi inop

Postby brandonb » Thu Nov 28, 2013 8:38 am

this works in flowcode, a brain glitch on my part :lol:
These users thanked the author brandonb for the post:
Benj (Thu Nov 28, 2013 10:30 am)
Rating: 5%
 

brandonb
Posts: 438
Joined: Mon Aug 29, 2011 12:26 am
Location: arizona
Has thanked: 175 times
Been thanked: 173 times
Contact:

Re: 12f1840 spi inop

Postby brandonb » Sat Nov 30, 2013 6:58 pm

ben: i was excited and forgot to initialize in flowcode.....im writing librarys for this by looking at datasheet and i found that any chip with 1800 in the name the sspif bit does not set when using it to determine message complete, this is kind of weird because its the way they instructed in datasheet and does work correctly on the 1900 chips, what i did to fix this in my code to determine when message is sent/received in which obviously is the way you guys do it because its the only way to make it work by polling the bf bit in sspstat in a while loop

Code: Select all

char spi_get(void){
  sspbuf=0;// send dummy
  while((sspstat&1)==0);// wait for done (BF_bit)
  return sspbuf;// return read
}

void spi_send(char send_it){
  sspbuf=send_it;
  while((sspstat&1)==0);// wait for done (BF_bit)
  send_it=sspbuf;
}
These users thanked the author brandonb for the post (total 2):
dazz (Sat Nov 30, 2013 9:00 pm) • Benj (Wed Dec 04, 2013 6:32 pm)
Rating: 10%