>From: Brendan Moran <
EraseMEannirack
SHAW.CA>
>Reply-To: pic microcontroller discussion list <
RemoveMEPICLISTEraseME
EraseMEMITVMA.MIT.EDU>
>To:
RemoveMEPICLISTspam_OUT
KILLspamMITVMA.MIT.EDU
>Subject: Re: [PIC]: PIC software
>Date: Fri, 4 Apr 2003 16:44:51 -0800
>
>>I was just a little confused as to why everyone thinks it is simpler to go
>>through the PIC. It is obviously more complicated in this case, unless
>>I'm
>>missing something big. Anyway, I just wanted to clear things up and make
>>sure I'm not messing up.
>
>You have read the I2C spec, right?
>www.semiconductors.philips.com/markets/mms/protocols/i2c/index.html
>www.semiconductors.philips.com/acrobat/various/I2C_BUS_SPECIFICATION_3.pdf
>Don't get your information anywhere other than that, unless you're looking
>at the specific behavior of a specific device. I2C is Philips' protocol,
>so it only makes sense to get whatever info you need from them.
>
>I2C is a somewhat complex serial protocol. The point is that the majority
>of current PICs implement I2C in hardware, and all you have to do is set
>some register values. From a parallel port, you have to do FAR more than
>that. And, besides, your transfer speeds would be abysmal since parallel
>ports (at least the figure I remember, though it may be better now) only do
>something like 5k refreshes/sec. That limits you to a maximum of ~1.67kbps
>as opposed to the 100kbps from IIC through a PIC on *slow* mode, never mind
>FAST or HS modes. (well, you're actually limited by the serial port at
>those speeds. 115kbps is the limit on the PC, and most level converters
>only handle up to 250kbps)
>
>Implementing an I2C master on a newer PIC is relatively easy, as I have
>said. So is implementing a serial transfer on a PIC. They both take
>straight parallel data writes and a bit set or two for enabling after
>initialization is done. If you're using either something from the 16F87x
>or (I think) 16F62x they have an I2C peripheral built in. No bit twiddling
>for you.
>
>If you're using a 16F84, get a new micro.
>
>all you have to do to get an idea of what's needed is to read the MSSP and
>USART sections of the relevant PIC datasheet, and the communication section
>of the EEPROM datasheet. They usually spell it out pretty well. And, if
>you check microchip's appnotes, there's probably an example, though I
>haven't looked.
>
>I cannot see how you could consider it more difficult to use a micro you
>already need than to write all the code needed for a parallel port to do
>the same job.
>
>As you pointed out, there're only 2 places that you need to write software
>that's any different from what you already need.
>
>Start by using the UART receive interrupt.
>When it interrupts, check if it's the transmit character that's been sent.
>If it is the right character, read a burst of data from the EEPROM into a
>buffer, then send it over the serial port.
>Loop reading and sending bursts of data until you hit the end of the
>EEPROM.
>Go back to doing whatever it is that your micro does
>
>If both your micro and your software know in advance the size of the
>EEPROM, it makes data frames and all such similar ideas irrelevant.
>
>Another thing you could do is provide a simple text interface from the
>micro. This is easy to do, just have the micro respond to a given
>character (say, a carriage return) by displaying its menu.
>
>You could make a menu item be to dump the data in an ascii encoded mode,
>where you convert each byte to its ascii hex value. This doubles the data
>size, but makes the data more readable (and it's still easy to process in
>C++ with all the existing string manipulation)
>Then, you could use a terminal program on the PC side, and not even need to
>write any PC software to grab the data, only to manipulate it into whatever
>form you need. You would also be able to use things like the End Of
>Transmission character to signal that it has reached the end of the
>available data.
>
>If you're worried about errors, use parity. If you're getting any errors,
>you should really check the link between your PC and your micro and
>recapture the data, so additional framing becomes redundant.
>
>Handling things with the PIC is way easier and, from a speed point of view,
>way better than the parallel port idea.
>
>--Brendan
>
>--
>
http://www.piclist.com hint: The PICList is archived three different
>ways. See
http://www.piclist.com/#archives for details.