CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

RS232 + SPI on 16F88

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

RS232 + SPI on 16F88
PostPosted: Tue May 29, 2012 10:21 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue May 29, 2012 3:22 pm     Reply with quote

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: 19540

View user's profile Send private message

PostPosted: Wed May 30, 2012 1:56 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed May 30, 2012 6:45 am     Reply with quote

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: 19540

View user's profile Send private message

PostPosted: Wed May 30, 2012 9:23 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu May 31, 2012 7:01 am     Reply with quote

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: 19540

View user's profile Send private message

PostPosted: Thu May 31, 2012 7:28 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group