View previous topic :: View next topic |
Author |
Message |
vinniewryan
Joined: 29 Jul 2009 Posts: 154 Location: at work
|
generate baud clk signal |
Posted: Thu Sep 02, 2010 4:36 pm |
|
|
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
|
|
Posted: Thu Sep 02, 2010 4:47 pm |
|
|
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
|
|
Posted: Thu Sep 02, 2010 4:54 pm |
|
|
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
|
|
Posted: Thu Sep 02, 2010 5:15 pm |
|
|
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
|
|
Posted: Fri Sep 03, 2010 12:43 pm |
|
|
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
|
|
Posted: Fri Sep 03, 2010 1:04 pm |
|
|
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
|
|
Posted: Mon Oct 25, 2010 6:26 pm |
|
|
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 |
|
|
|