Posted: Mon Feb 09, 2009 7:49 pm Post subject: Using SPI pin for general I/O
I recently had an issue with Portb.4 on a Mega16. I have a motor running between two soft limits (reed switches) every so often the motor would "glitch" as if one of the limits was being hit and occasionally it would miss one of the soft limits (always the same one) completely and hit the hard limit shutting the system down. Turned out that the affected soft limit was connected to Portb.4 which is one of the SPI lines, moving everything to Portc solved the problem, but I could do with using PortB for general I/O so I guess I have to disable the use of port B for SPI somehow?
Joined: 16 Jan 2006 Posts: 2483 Location: Queensland
Posted: Mon Feb 09, 2009 10:37 pm Post subject:
SPI is only enabled if you use the CONFIG SPI = HARD command in Bascom, else it is disabled by default on startup. As long as SPI is not enabled, you should be able to use the port for general I/O.
Be aware some development boards insert resistors into the SPI lines since they are also used for ISP programming. Again, as long as you disconnect the ISP interface, you can use those lines as general I/O. _________________ Adrian Jansen
Computer language is a framework for creativity
>Be aware some development boards insert resistors into the SPI lines since
>they are also used for ISP programming.
I did wonder about that but B.4 is the SS line and isn't used for programming. It could simply be that that pin is borked, when I get a chance I'll swap it out for a new chip, unfortunately it's now running an automated test which would be a real pain to abort and re-start.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum