Translation Problem


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by cyh_fax View Post
    I translated the following PicBasic Code to ProBasic Pro. Could any one please check whether my translation is 100% correct since it does compile without an error but the actual circuit doesn't work. [The circuit does work with the code compiled from PicBasic].

    --------------------------------------------------------------------------
    'PicBasic
    symbol porta = 5
    symbol trisa = 133
    symbol portb = 6
    symbol trisb = 134
    poke trisa, 255
    poke trisb, 240
    start:
    peek portb, b0
    if bit4 = 0 then trigger
    goto start
    trigger:
    pause 500
    peek portb, b0
    if bit5 = 1 then send
    goto start
    send:
    peek porta, b0
    if bit4 = 1 then eleven
    poke portb, b0
    goto start
    eleven:
    if bit0 = 0 then ten
    poke portb, 11
    goto start
    ten:
    poke portb, 10
    goto start
    end
    --------------------------------------------------------------------------

    --------------------------------------------------------------------------
    'PicBasic Pro
    trisa = 255
    trisb = 240
    p var byte
    start:
    p = portb
    if p.4 = 0 then trigger
    goto start
    trigger:
    pause 500
    p = portb
    if p.5 = 1 then send
    goto start
    send:
    p = porta
    if p.4 = 1 then eleven
    portb = p
    goto start
    eleven:
    if p.0 = 0 then ten
    portb = 11
    goto start
    ten:
    portb = 10
    goto start
    end
    --------------------------------------------------------------------------
    You might try:
    Code:
    trisa = 255
    trisb = 240
    p var byte
    
    start:
    p = portb
    if p.4 = 0 then goto trigger
    goto start
    
    trigger:
    pause 500
    p = portb
    if p.5 = 1 then goto send
    goto start
    
    send:
    p = porta
    if p.4 = 1 then goto eleven
    portb = p
    goto start
    
    eleven:
    if p.0 = 0 then goto ten
    portb = 11
    goto start
    
    ten:
    portb = 10
    goto start
    end
    I know some will object to goto's as sloppy, but if it works . .
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  2. #2
    jessey's Avatar
    jessey Guest


    Did you find this post helpful? Yes | No

    Default If - Then's instead of GOTO's

    Quote Originally Posted by Joe S. View Post
    I know some will object to goto's as sloppy, but if it works . .
    Why not set a variable bit, say A to equal 0 then use "IF A = 0 THEN Start", then don't use the bit variable for nothing else. Thats what I do instead of using GOTO's and the IF - THEN's only uses 2 words. Good approach I think, if your not really tight for code space.

    jessey

Similar Threads

  1. USART Problem , but don't know where, in pc? or in PIC?
    By precision in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th July 2007, 09:12
  2. PicBasic Pro Math Problem??
    By Glen65 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th March 2006, 05:36
  3. 1 slave 1 master 1 MAX232 1 problem ?
    By SuB-ZeRo in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 31st July 2005, 23:59
  4. weird 12F629/675 problem
    By peterdeco1 in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 7th October 2004, 02:08
  5. PORTA.PinNo = 1 ' problem
    By frank small in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 6th May 2004, 15:30

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