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

Running UART with external clock

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



Joined: 06 Nov 2013
Posts: 27

View user's profile Send private message

Running UART with external clock
PostPosted: Wed Nov 06, 2013 10:22 am     Reply with quote

Hello Forum.
Trying to build a SIM emulator and the documentation says that the SIM must follow the external clock of the interface. My first thought was to use UART, but how can i use UART with a external clock? Also a serial byte must be read/write every 372 clocks to interpret the data correctly. Any thoughts?
I'm running on 18f14k50 on 32M speed on PCH 4.124. Thank you very much.
temtronic



Joined: 01 Jul 2010
Posts: 9229
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Nov 06, 2013 11:04 am     Reply with quote

First thought is that you should post a link to whatever documentation is related to 'SIM emulator'. I can't be the only guy here who has no clue what it is....

2nd thought..syncing every 372 clocks is easy as is the reading/writing, depending on the real speed of the I/O operations

jay
pulurumbuluruciu



Joined: 06 Nov 2013
Posts: 27

View user's profile Send private message

PostPosted: Wed Nov 06, 2013 11:09 am     Reply with quote

http://www.cardwerk.com/smartcards/smartcard_standard_ISO7816-3.aspx

Sorry for confusion. The protocol is 7816. "Sim emulator" as a ISO 7816 SMART CARD EMULATOR.
Ttelmah



Joined: 11 Mar 2010
Posts: 19520

View user's profile Send private message

PostPosted: Wed Nov 06, 2013 11:57 am     Reply with quote

I'd say, you probably should look for a PIC that has a USART, rather than UART. This then allows data transfers to be synchronised to an external clock. Then triggering the transmission after 'x' clocks, would be easily done using the CCP. I'm fairly sure the 14K50 does have a USART, so you should be able to select 'SYNC_SLAVE' in the #use_rs232, which will then clock bits on the external clock. Start the transmission after 371 clocks, and the data will clock out on the next clock.

Best Wishes
pulurumbuluruciu



Joined: 06 Nov 2013
Posts: 27

View user's profile Send private message

PostPosted: Wed Nov 06, 2013 12:40 pm     Reply with quote

Indeed it has a USART, but how can i make the CCP trigger at 372? using timer0 or timer1? How can i make the timer interrupt exactly at 372 external pulses?
Ttelmah



Joined: 11 Mar 2010
Posts: 19520

View user's profile Send private message

PostPosted: Thu Nov 07, 2013 1:15 am     Reply with quote

You'd want it to trigger one pulse earlier. The data starts transferring on the _next_ clock after the UART register is loaded. Hence my 371.

You'd need to feed the clock into two pins on the PIC, The USART synchronous clock input, and the CCP timer input (for count modes, normally Timer1). Setup the timer to count using the external clock.

Then program the CCP register to 371, and reset the timer. 371 clocks later the CCP will trigger, and you load the USART register.

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