12f1840 spi inop

Moderator: Benj

Post Reply
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

Post by brandonb »

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

Post by brandonb »

this works in flowcode, a brain glitch on my part :lol:

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

Post by brandonb »

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

Post Reply