PDA

View Full Version : Trying to use PIC18F4520 to do asynchronous serial transmit to PC



TurboLS
- 15th February 2005, 21:50
OK, we are using this PIC18F4520 to do a few things:

1.) Generate 5 TTL clocking signals for a CCD
- we are using a 20Mhz ceramic resonator and we have EPIC Win set to HS when programming. We have the first and third pins of the resonator wired to OSC1 and OSC2 (pins 13 and 14 on the PIC), respectively.

2.) Acquire analog data from the CCD and convert to 8 - 10 bit word for serial transmission. (the faster we can do these conversions and send them out the better).

3.) Eventually use some sort of interrupt to start the clocking signals and the A/D process and end it as well.

My questions are as follows:

First of all, how do I wire the **** thing up to a serial connection? Can I just use any 8 digital I/O ports in sequence?

Also, I know the manual says this chip does 10-bit A/D, but if I want to use asynchronous serial transmission, I think 8-bit would work better, is there any way to select that?

All programming is being done in PicBasic Pro and EPIC Win.

NavMicroSystems
- 15th February 2005, 22:08
TurboLS

it's all in the Manual

for AD-conversion see:

ADCIN see section 5.2
("DEFINE ADC_BITS 8")

for serial communication see:

"SERIN" section 5.71
"SERIN2" section 5.72
"SEROUT" section 5.73
"SEROUT2" section 5.74
"HSERIN" section 5.30
"HSEROUT" section 5.32

toalan
- 23rd February 2005, 17:53
take your 10 bit value and divide by 4 and get an 8 bit value, you lose 2 bits of resolution. after you divide by 4 just send it out using Serout or Hserout, you can send out a 10 bit word variable as long as it is less than 256, IE it will only send out the lower 8 bits of the 10 bit variable.

TurboLS
- 23rd February 2005, 17:59
Oh yeah, I got all the serial transfer stuff working. Thanks again guys.