High Speed Serial Comm PC - PIC and PIC - PIC


Closed Thread
Results 1 to 24 of 24

Hybrid View

  1. #1
    Join Date
    Jan 2007
    Posts
    44

    Question High Speed Serial Comm PC - PIC and PIC - PIC

    Hi. I am 15, and I quite a newby in PICs.
    I am working on a LED cube project, and need to send 32, 64, or 96 bytes through serial communication. Which is the higher speed I can get running at 20 Mhz??? And running at 40 MHz???
    Also, is it better to use the USART module??? How does it work???
    I hope you cal help me!!! This is a great forum!!!!
    Thanks
    Manuel

    PS I hope i posted this thread in the right place!

  2. #2
    Join Date
    Oct 2004
    Location
    Hangover, Germany
    Posts
    289


    Did you find this post helpful? Yes | No

    Default

    Yes, it is better to use the USART-Hardware.
    What speed is your PC able to handle on his serial port ?
    I think, the PIC will manage it also!
    PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2

  3. #3
    Join Date
    Jan 2007
    Posts
    44


    Did you find this post helpful? Yes | No

    Default ---

    Hi. Thank you for your answer. I have no idea what serial speed my serial port can take. I may also end up using a USB - to - Serial adapter just in case i burn everything!!! ahah.
    Is it possible to reach speeds like 115200 bits per second with pics???
    Sorry for my english!! Spanish is my first languaje!!!! Thanks
    Manuel

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by manumenzella View Post
    Hi. Thank you for your answer. I have no idea what serial speed my serial port can take. I may also end up using a USB - to - Serial adapter just in case i burn everything!!! ahah.
    Is it possible to reach speeds like 115200 bits per second with pics???
    Sorry for my english!! Spanish is my first languaje!!!! Thanks
    Manuel
    Yes, you can get 115.2kbps from a PIC. You can get all the way up to 2.5Mbps (40mhz clock / 16), but you'll barely have any time left over to move data around and otherwise process it.

  5. #5
    Join Date
    Jan 2007
    Posts
    44


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    Yes, you can get 115.2kbps from a PIC. You can get all the way up to 2.5Mbps (40mhz clock / 16), but you'll barely have any time left over to move data around and otherwise process it.
    Hi skimask! Thank you for your answer!!! I don't need the data to be receiver all the time. Just about 96 bytes twenty times every second. By the way, I think there is something i don't understand about the USART: is it like the serin/out, in which the pic has to do OLNY the serial transmission, and cannot do anything else, or is it like HPWM, a background process??? (I dont think i made that very clear.. my english is not that good..
    Sorry to bother you again!!! And thanks!!!!!!!
    Manuel

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by manumenzella View Post
    Hi skimask! Thank you for your answer!!! I don't need the data to be receiver all the time. Just about 96 bytes twenty times every second. By the way, I think there is something i don't understand about the USART: is it like the serin/out, in which the pic has to do OLNY the serial transmission, and cannot do anything else, or is it like HPWM, a background process??? (I dont think i made that very clear.. my english is not that good..
    Sorry to bother you again!!! And thanks!!!!!!!
    Manuel


    Serin/Serout is a 'bit-banged' routine, all bits are checked/timed using software, delays, loops, etc. Once you're in the middle of a Serin/Serout command, that's all you can do, nothing else.

    HSerin/HSerout is a mix between software and hardware, done somewhat in the 'background' but not entirely. Hardware handles receiving/transmitting the character, PBP software handles 'getting' or 'sending' it. Again, once you're in the middle of a command, you have to wait until it's finished.

    The UART is completely hardware driven. You can either set up a loop and wait for certain bits to change, then act on the sending/receiving registers accordingly. Or you can do use the UART in the 'background' using interrupts to tell you when you need to receive or send characters.

    Your PBP manual has a decent explanation of how to use the Serin/Serout/HSerin/HSerout and the PIC datasheets do well explaining the UART. Use them...they are your friend...

  7. #7
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by manumenzella View Post
    ... I think there is something i don't understand about the USART: is it like the serin/out, in which the pic has to do OLNY the serial transmission, and cannot do anything else, or is it like HPWM, a background process???
    Manuel,
    The harware USART operates in the background, as does the HWPM. However, you do have to "feed" it the data, and that will essentially happen one byte at a time.

    You say you need to send 96 bytes at a time, twenty times a second? From your previous mention of 40MHz clock speed, I would deduce you are using an 18F PIC. I don't know how you are "gathering" your 96 bytes of data, but you could feed the USART from an array using interrupts to determine when the USART is able to receive the next byte. You may also be able to poll the TXIF bit frequently vs using interrupts.

    Hopefully, this is not sounding too advanced. Start by reading the PBP manual on HSEROUT and the datasheet for you pic (the USART section). Also, MeLabs has some sample programs that can also help.

    The basics are:
    1) Setup the USART through the approapriate DEFINEs and registers. Here is an example of what I use for a 18F4620:
    Code:
    '	'Setup for 115200 baud 
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    DEFINE HSER_SPBRG 86  ' 86 = 115200 Baud @ -0.22%
    SPBRGH = 0
    BAUDCON.3 = 1         ' Enable 16 bit baudrate generator
    2) Use either:
    a) HSEROUT to send out the data, realizing that it can do some processing of the data before it is sent to the hardware. Also, that sending multiple bytes of data will force the PIC to process all the bytes to be sent out before it moves on to the next statement
    b) Send the bytes directly to TXREG. This would allow for the use of interrupts/flag polling to send the data "in the background"

    Hope this helps you get started in the right direction.
    Steve B

    Guess I was a little slow on the draw That's what happens when toddlers need to go to sleep!
    Last edited by SteveB; - 15th January 2007 at 01:53. Reason: Skimask beat me to the punch!

Similar Threads

  1. Replies: 11
    Last Post: - 12th July 2008, 02:36
  2. Pic to pic interrupt ans serial comm
    By ronjodu in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 10th May 2008, 22:43
  3. pc to pic serial comm and i2c eeprom
    By elektroline in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 2nd November 2006, 05:51
  4. Replies: 5
    Last Post: - 20th March 2006, 01:34
  5. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th March 2005, 23:14

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts