serial communication time


Closed Thread
Results 1 to 28 of 28

Hybrid View

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


    Did you find this post helpful? Yes | No

    Question Serial com with DEBUG

    Thanks for your Help so long Guys.

    As you know I will do as You tell and try. So I bought everything I need to try parallel com between pics but at first I will give "Debug" a try because its so fast (I read about that)

    Sending (with all the Defines at Baud rate 9600)

    CNT Var Byte
    ....
    ....
    Debug [cnt]


    Recieving (same Definitions)

    Debugin ; cnt

    .....
    LCDOUT $FE02 `something like that, worked before
    LCDOUT $FE80 "CNT=" , CNT
    ...

    I´m not absolute shure about the code BUT

    The LCD Display recieves something but only one Element which changes when changing the Input frequency
    It shows CNT=§ (its the german symbol for "Divide" I dont have it on my keyboard)
    or CNT=A (but only half symbol height and square)

    This shows the transmission works, its just like different languages.
    When I use Serout/Serin everything works fine
    then it shows "CNT=146" for example whith input freq 146Hz .

    There must be more about Debug/Debugin
    I tried changing the Var defines from byte to dec which changed the display from rubbish to rubbish .

    I thought if i´m sending a Var frompic to pic then it doesn´t change. Obvious it does.
    What I´mmissing?
    I´m showing the precise program code today in the evenig when I´m back home.
    I need just a simple example for sending a byte by debug from pic to pic.
    Oh yes I dream of baud rate 120000 or something....

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


    Did you find this post helpful? Yes | No

    Default program:here we are

    This is for sending the variable "CNT"
    ' DEFINITIONS
    Include "modedefs.bas"
    CMCON=%00000111
    DEFINE OSC 4
    DEFINE DEBUG_REG PORTB
    DEFINE DEBUG_BIT 2
    DEFINE DEBUG_MODE 0 '1 = Inverted, 0 = true
    DEFINE DEBUG_BAUD 9600

    Cnt VAR Word ' Cnt is a word variable
    CMCON = 7 ' RA0-RA3 are digital I/O
    TRISA = 0 ' PORT A is output
    TRISB = %01111111 ' RB7 is Input others output
    cnt = 0
    main:

    COUNT PORTA.2,100,cnt ' Count for 1 second
    DEBUG cnt

    goto main


    END ' End of program

    And this is for recieving

    '
    ' DEFINITIONS
    Include "modedefs.bas"
    CMCON=%00000111
    DEFINE OSC 4
    DEFINE DEBUGIN_REG PORTB
    DEFINE DEBUGIN_BIT 1
    DEFINE DEBUGIN_MODE 0 '1 = Inverted, 0 = true
    DEFINE DEBUGIN_BAUD 9600

    Cnt VAR Word ' Cnt is a word variable
    CMCON = 7 ' RA0-RA3 are digital I/O
    TRISA = 0 ' PORT A is output
    TRISB = %11111101 ' RB1 is Input others output
    cnt = 0

    main:


    debugin [cnt]


    LCDOUT $FE,2
    LCDOUT "cnt=", cnt
    goto main



    goto main


    END ' End of program
    and it shows just rubbish as told in the post above.
    Any Hint?`

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Code:
    LCDOUT $FE , 2 , "cnt=" , DEC cnt
    Just like the good book says...
    That rubbish you say was the ASCII representation of the value in cnt.

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


    Did you find this post helpful? Yes | No

    Default Debug Problem only last Digit changing

    Hi Skimask,

    I did as You told but now my LCD shows

    cnt=252 or cnt=253

    thats the only change

    Any hint?

    Greetings from a desperate mechanical engineer

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


    Did you find this post helpful? Yes | No

    Default Works now but waaaaay too slow

    Hi Skimask,

    I changed my program into this:

    '
    ' DEFINITIONS
    Include "modedefs.bas"
    CMCON=%00000111
    DEFINE OSC 4
    DEFINE DEBUGIN_REG PORTB
    DEFINE DEBUGIN_BIT 1
    DEFINE DEBUGIN_MODE 0 '1 = Inverted, 0 = true
    DEFINE DEBUGIN_BAUD 2400

    Cnt VAR Word ' Cnt is a word variable
    CMCON = 7 ' RA0-RA3 are digital I/O
    TRISA = 0 ' PORT A is output
    TRISB = %11111101 ' RB1 is Input others output
    cnt = 0

    main:


    debugin [cnt]


    LCDOUT $FE,2 ' Home cursor
    LCDOUT "CNT=", DEC3 Cnt

    goto main



    goto main


    END ' End of program

    Now it works but only with this Baud rate of 2400.

    BUT I WANT a Baud rate of ONE ZILLION or so.

    seems I´m still at the beginning.

    Or is it possible to run the data transfer in the background using some asm code ?

    Greetings from Mugel

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Mugelpower View Post
    Now it works but only with this Baud rate of 2400.
    BUT I WANT a Baud rate of ONE ZILLION or so.
    seems I´m still at the beginning.
    Or is it possible to run the data transfer in the background using some asm code ?
    Greetings from Mugel
    I guess I still don't get what you're trying to accomplish in the end.

    It probably works at 2400 baud because there's enough time in between transmitted characters to send the data out to the LCD. At higher speed, when PBP returns from displaying to the LCD, the next transmission/reception is already halfway done and it gets missed. Either that or your oscillator is out of tolerance.

    As far as using high baud rates, no you don't really need asm code...just a good understanding of the PIC, it's registers, the USART module, and some interrupts.

    And it seems I'm right back to saying what I said back on 1Feb...

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


    Did you find this post helpful? Yes | No

    Smile Need for Speed because:

    Hello famous Skimask,

    my LCD is only for controlling the principal of transmission.

    I got 3 Pics together:

    1. : getting Input, storing freq in VAR "CNT" and sending out with Debug
    2. : taking the VAR "CNT" with Debugin, calculating a Delay and sending out a 1ms Pulse
    after RB0 gets High + Delay time.
    3. : taking the VAR "CNT" and showing on LCD just for control purposes

    Showing my extremes:

    a)cranking a 4-cyl. engine makes about 180/min. with a fixed 50° before OT input signal we need a delay of 37 ms until Ignition which makes 10° before OT which is great for starting an engine.

    b) 4cyl 8000/min: we need only 0.2ms Delay after fixed 50° Input signal to get 40° before OT Ignition which may be great for a racing engine.

    The delay has to include the PICs intern calculation delay.
    The calculation could be done in the first PIC which measures only 10 times a second
    BUT the "Execution PIC" has only about 1.5 ms for receiving the Var and being ready for the next action.
    And an 8cyl at 6000/min leaves only 0.8 ms.
    thats why I need transmission speed

Similar Threads

  1. Replies: 5
    Last Post: - 20th March 2006, 01:34
  2. Bootloader,MCSP and Serial communication
    By surfer0815 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 3rd March 2006, 10:52
  3. Serial Communication using 12F629
    By charudatt in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 14th March 2005, 04:24
  4. Serial communication PIC to PIC help.
    By Rubicon in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 24th January 2005, 15:45
  5. Replies: 8
    Last Post: - 11th November 2004, 20: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