View previous topic :: View next topic |
Author |
Message |
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
RS232 + SPI on 16F88 |
Posted: Tue May 29, 2012 10:21 am |
|
|
Hi,
Has anyone tried using SPI and RS232 at the same time on a 16F88?
The RX(232) and SDO(SPI) share the same pin.
I don't anticipate this to be a problem since the SPI chips have to be enabled to work and depending on the serial type its either an input or an output...
Dumping the contents of an SPI EEPROM over 232 might be tricky....
thoughts?
Gabriel _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
|
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Tue May 29, 2012 3:22 pm |
|
|
hmm, SDO might/will trigger the RX ISR ?
Collision issues when receiving a 232 char, and writing to EEPROM ? _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19520
|
|
Posted: Wed May 30, 2012 1:56 am |
|
|
Realistically, use software SPI.
Remember CCS gives this if you select non hardware pins for the SPI. Since SPI is synchronous, slight changes in the bit times as code goes off to handle RS232 interrupts etc., don't matter at all, making this simple, and safe.
Best Wishes |
|
|
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Wed May 30, 2012 6:45 am |
|
|
Hey, thanks for the reply...
I already have the board made... its a prototype I made some time ago that I'm trying to bring to life.... and well i kinda have to live with the design flaws.
So I can't separate the SDO / RX functions from the pin.
Its one of those things i designed and build on some hyped moment... never tested,,,, found it 6 months later... and think WTF to my self...and challenged myself to get it to work.
I do not need to receive anything from 232 while dumping EEPROM data... so I'm thinking i can just use careful timing to get past this obstacle.
I'm not really against some performance sacrifices... _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19520
|
|
Posted: Wed May 30, 2012 9:23 am |
|
|
You can turn the UART ON/OFF. If you setup your #use RS232, with 'BAUD=0', the UART will not be started. Then when you want to use the UART, use 'setup_uart(BAUD_RATE);' to turn the UART on. When you want to stop using the UART 'setup_uart(0);' then turns it off.
If you want to just turn of the RX part, then CCS doesn't supply a function for this, (nor, does the hardware directly), but you can do it by turning off the CREN bit, and again enabling this once all SPI work is finished. You will need to ensure the line is high before this happens. Presumably you have some method of enabling/disabling the RS232 receive buffer?. So enable this, check the line has gone high, then re-enable the receive.
Best Wishes |
|
|
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Thu May 31, 2012 7:01 am |
|
|
Thanks Ttelmah... Ill try the Baud=0 trick... i didnt know that.
I was thinking of disabling the INT_RDA interrupt so that the buffer does not get any data or a global flag+IF that allows the interrupt to fire but not write to the buffer...
hmm ... interesting... ill throw some code together and let people know what i find...
thanks! _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19520
|
|
Posted: Thu May 31, 2012 7:28 am |
|
|
Gabriel wrote: | Thanks Ttelmah... Ill try the Baud=0 trick... i didnt know that.
I was thinking of disabling the INT_RDA interrupt so that the buffer does not get any data or a global flag+IF that allows the interrupt to fire but not write to the buffer...
hmm ... interesting... ill throw some code together and let people know what i find...
thanks! |
Problem with that, is that the UART will then be hung. If data is received, and not handled and the internal buffer (1.9999 characters) overruns, you trigger an overrun error (OERR). This disables the UART. Too clear this you have to turn the RX UART off, then on again. The 'ERRORS' option in #USR RS232 does this for you, but only when getc is called.....
Best Wishes |
|
|
|