c - Pic to Pic communcation through SPI -


i trying make pic1 master , pic2 slave through spi communication. want send command pic1 (master) pic2 (slave), have something. want establish spi communication pic2 (slave) digital potentiometer (mcp4241) through spi communication well. work ?

to illustrate :

pic1 sends 'a' ---- > pic2 reads

pic2 ---- > establishes connection digital pot(mcp4241)

pic2 ---- > sends data digital pot

so there spi communications between pic1 , pic2, pic2 , digital pot, don't know if going work since need use same pins. 2 pics, using pic16f690.

i hope question clear , please if won't work how should fix it?

thanks!

first of all, easy life, i'd recommend using pic 2 spi ports pic2.

however, if sure want use 1 spi port master , slave thing keep in mind don't want both pics try drive serial line @ same time. may have write tris registers make port tristate go high-z disabling spi peripheral.

  • if put series resistors in things less bad if e.g. pic1 tries drive sclk high while pic2 trying drive low current flowing pic1 pic2 limited

  • you use gpio allow pic2 tell pic1 when busy. need have clear idea of flow of execution between 2 devices don't caught race conditions etc

  • for example have flow of

  • pic1 sends 'write pot please' command pic2
  • pic1 knows wait busy signal
  • pic2 asserts busy signal
  • pic1 sees busy signal , knows wait clear before starting spi transaction
  • pic2 spi transaction pot
  • pic2 clears busy signal
  • pic1 sees busy signal has cleared , knows ok spi transactions
  • pic2 not try spi transaction until gets 'write pot please'

there loads of ways implement this. important thing know flow going before start implementation


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -