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 support@ccsinfo.com

generate baud clk signal

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



Joined: 29 Jul 2009
Posts: 154
Location: at work

View user's profile Send private message MSN Messenger

generate baud clk signal
PostPosted: Thu Sep 02, 2010 4:36 pm     Reply with quote

I'm working with the MCP2122 'Serial to IR Encoder/Decoder' which has a 16XCLK input pin. I need to somehow generate a baud clk signal from a pin on my 16f684 to connect to the 16XCLK pin on the IR chip. Is there an easy way to do this? I read through the CCS Manual and found "SYNC_MASTER" under '#use RS232' configuration which says "Makes the RS232 line a synchronous master, making
the receive pin a clock out, and the data pin the data
in/out.", but when I tried to use configuration, I got an error "USE parameter value is out of range H/W USART required". Any suggestions?

Compiler V4.033

Thanks!
_________________
Vinnie Ryan
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Sep 02, 2010 4:47 pm     Reply with quote

Change your PIC to a 16F688. It's a 14-pin package, but it has a
hardware UART.
vinniewryan



Joined: 29 Jul 2009
Posts: 154
Location: at work

View user's profile Send private message MSN Messenger

PostPosted: Thu Sep 02, 2010 4:54 pm     Reply with quote

I tried changing it to 16f688 but I'm still getting the same error..


This is my current config:
Code:

#include "16f688.h"
#use delay(clock=4000000)
#use RS232(BAUD=9600,SYNC_MASTER,RCV=pin_a1,XMIT=pin_a2)

_________________
Vinnie Ryan
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Sep 02, 2010 5:15 pm     Reply with quote

You have to use the hardware pins, on C4 and C5. Check the pinout
diagram in the data sheet.
vinniewryan



Joined: 29 Jul 2009
Posts: 154
Location: at work

View user's profile Send private message MSN Messenger

PostPosted: Fri Sep 03, 2010 12:43 pm     Reply with quote

Thanks PCM, I ordered some 16f688's today. I'm just trying to send ADC data from pic to pic via IR.
_________________
Vinnie Ryan
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Fri Sep 03, 2010 1:04 pm     Reply with quote

Unfortunately, your idea of using SYNC_MASTER mode doesn't work, I think.

IrDA needs to interface to a standard asynchronous UART, but must be supplied with a 16x bit clock, 153600 kHz for 9600 baud. With a PIC processor you need an additional timer output for the CLKx16, and the crystal frequency must allow it. E.g. a standard UART crystal like 3.686 MHz and multiples of it will work. If you don't have free timer resources, you can use a hardware frequency divider.

It should be noticed, than you can get IrDA chips from other vendors that have programmable baud generators, e.g. from Vishay.

More advanced processors like PIC24 have built-in IrDA interfaces.
vinniewryan



Joined: 29 Jul 2009
Posts: 154
Location: at work

View user's profile Send private message MSN Messenger

PostPosted: Mon Oct 25, 2010 6:26 pm     Reply with quote

Thanks for the responses. After snooping around some more, I found a nifty document on Microchip's website titled "AN946" which provides all the info about generating the clock signal. A simple Timer2/CCP is all that's needed, generating a clock signal of 16X the desired baud rate.

Thanks again!
_________________
Vinnie Ryan
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