High Speed Serial Comm PC - PIC and PIC - PIC


Results 1 to 24 of 24

Threaded View

  1. #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 02:53. Reason: Skimask beat me to the punch!

Similar Threads

  1. Replies: 11
    Last Post: - 12th July 2008, 03:36
  2. Pic to pic interrupt ans serial comm
    By ronjodu in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 10th May 2008, 23: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, 06:51
  4. Replies: 5
    Last Post: - 20th March 2006, 02:34
  5. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 12th March 2005, 00:14

Members who have read this thread : 0

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