serial communication time


Closed Thread
Results 1 to 28 of 28

Hybrid View

  1. #1
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Mugelpower View Post
    only 0.4 ms or less to send the data from one pic
    I think it is sufficient to transmit that data every 0.1 sec.
    9600 baud = 9600 bits per second
    1 second / 9600 = .1046 ms per bit
    1 byte = 8 bits + start bit + stop bit = 10.5 bits
    10.5 x .1046 = 1.0983ms per single data byte = 910.498 bytes per second MAX

    The math doesn't work...

  2. #2
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Default

    Mugel,

    It is not clear to me what you are trying to do. If you use the Hardware USART, you can send and receive in the "background" and keep your programs doing what they need to do.

    Further, are you using RS232? Why Pulsout shown in the ISR?

    More details = more help
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  3. #3
    Join Date
    Jan 2008
    Location
    Selm, Germany
    Posts
    116


    Did you find this post helpful? Yes | No

    Default USART please but how to use ?

    oha,
    1 ms for Data transfer is way too much. And recieving data (no sending!) in the background seems the only thing to do
    '************************************************* *******************************************
    ' 16F628A 10 Mhz crystal 15pf capacitors
    ' damn program should blink an LED every time a pulse goes into RB.0
    ' later a value should be serial loaded and set a delay before the blink pulse
    '************************************************* *******************************************

    '
    ' DEFINITIONS


    DEFINE OSC 10
    CMCON=%00000111
    inputData var word ' variable to receive data into
    pulseWidthVar var word



    ' START OF MAIN PROGRAM
    '
    CMCON = 7 ' RA0-RA3 are digital I/O
    TRISA = 0 ' PORT A is output
    TRISB = 1 ' RB0 is Input others output


    on interrupt goto ISr

    INTCON.1 = 0 ; Clear External Interrupt Flag
    INTCON.4 = 1 ; Enable External Interrupt



    main:
    Portb.7 = 0

    serin2 portB.0,16468, [inputData] 'for the future to load a value
    pulseWidthVar = inputData

    goto main

    disable

    ISR:

    portb.7 = 1 'blink LED 0.02 sec one time when RB.0 goes high
    pauseus 500
    portb.7 = 0
    INTCON.1 = 0 ; Clear External Interrupt Flag
    RESUME 'resume main program
    Enable 'Enable interrupts

    END ' End of program

    In my picbasic pro book from Dogan Ibrahim it says " USART is very complicated"
    and that did not encourage me.
    Because I use only 16F628A , maybe with 10Mhz that should do.

    How could I use the Usart . I think those 16F628A have one....

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Then throw that book away

    HSERIN is one, method. Reading the USART register is another one, using it's interrupt is a third one.

    Now you have to determine which process is much important. If you really have a need for speed for your interrupt, you may need to switch to Darrel's Instant-Interrupt. Not enough? ... use ASM interrupts.

    @10MHz, you could use a 57600 baud communication without too much problem.

    Not sure of your whole requirement... but i would use USART interrupt for that... i'll read it again.. just to make sure i didn't miss the main idea.
    Last edited by mister_e; - 30th January 2008 at 22:19.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    Join Date
    Jan 2008
    Location
    Selm, Germany
    Posts
    116


    Did you find this post helpful? Yes | No

    Default Baud rate/Usart speed

    Hi Mister_E,

    you helped me a lot last time I remember. OK. Principle is an Ignition that gets an input signal (raising edge on Portb.7) , starts an interrupt and after a "Delay" it sends a 0.5 ms High to an Output. After that it recieves serial the actual variable "Delay" which is a byte and is ready for the next interrupt.
    This all in about 1.5 ms at maximum speed.
    I have a second PIC that measures pulse width and calulates "Delay" so I save Time and code for the time critical Interrupt.

    But the Delay caused by the PBP program including the serial communication is about 1ms thats way too much.

  6. #6
    Join Date
    Jan 2008
    Location
    Selm, Germany
    Posts
    116


    Did you find this post helpful? Yes | No

    Default Raising edge on Port

    I meant Portb.0 as input of course...

  7. #7
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Default

    Mugel,

    How is it coming?

    I am still not clear what you are trying to do.

    I also am not clear on what is causing your 1mS latency ... is it the actual send time of the serial data?

    To me, it looks like you could use the USART on both the send program and the receive program and never really have to wait.

    Here is MELABS example program on USARTS

    http://www.melabs.com/resources/samples/pbp/usart.bas

    Once the USART is configured then sending data is as easy as

    TXREG = DATA1 ; where DATA1 is your Byte variable to send, your program continues on and the data is sent in the background

    And receiving DATA is as easy as

    DATA2 = RCREG ; where DATA2 is your Byte variable, your program can be doing other things while the data is coming in. Once the byte has been received in the background, your program can grab the data like this.

    It looks like to me you could do what I think you want to do with the USART and without Interrupts.

    Again, more details = more help
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

Similar Threads

  1. Replies: 5
    Last Post: - 20th March 2006, 02:34
  2. Bootloader,MCSP and Serial communication
    By surfer0815 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 3rd March 2006, 11:52
  3. Serial Communication using 12F629
    By charudatt in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 14th March 2005, 05:24
  4. Serial communication PIC to PIC help.
    By Rubicon in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 24th January 2005, 16:45
  5. Replies: 8
    Last Post: - 11th November 2004, 21:08

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