Shop OBEX P1 Docs P2 Docs Learn Events
bug IO with Sxsim — Parallax Forums

bug IO with Sxsim

Jean BrunetJean Brunet Posts: 10
edited 2006-11-07 20:22 in General Discussion
Hello,

I am a problem. Look

In I/O panel I put ra port = 0101

If ra port is IN, it work good
But in my program the ra port is IN or OUT

If ra port is OUT,
mov !ra,#%0000
mov ra,#$OB

But when I replace ra port IN
mov !ra,#%1111
mov w,ra

The program not look my change and the read of ra port is 0B, not 5 !!
And sxsim look a bug·mad.gif· but my program is good.tongue.gif

Jean
·

Comments

  • PJMontyPJMonty Posts: 983
    edited 2006-11-07 19:56
    Jean,

    Post complete working source code and let others help you find out if your code is good. If possible, make a SMALL program that demonstrates the problem.
      Thanks, PeterM
  • Jean BrunetJean Brunet Posts: 10
    edited 2006-11-07 20:22
    Yes,

    The program is a driver for the FT245R ship.
    The PC get "1" and the sx put a $0B response.
    At the second main loop, the ra port have a persistent information $0B.

    For testing the program, set rb.0, rb.2 and ra.0
    At the first, the program loop at read_usb.
    clear rb.0, and for write_usb clear rb.2

    Look ra port.
    The sx write $OB, and at the second read_usb the ra port are not refresh. The result is $Ob, not 1.

    Jean


    ···DEVICE· SX28,OSCHS3
    ··DEVICE· turbo,STACKX, OPTIONX
    ··IRC_CAL IRC_FAST
    ··ID····· 'CCD02'···;program ID label
    ··RESET·· reset_entry··;set reset/boot address
    ··FREQ·50_000_000

    RXF·=·rb.0· ; in. inv
    URD·=·rb.1· ; out. inv
    TXE·=·rb.2· ; in. inv
    WR·=·rb.3· ; out
    org·08H

    temp·ds·1
    data·ds·1

    reset_entry··MOV·M,#$0F
    ··MOV·!RA,#%1111·; Place le port A en entrée/sortie
    ··MOV·!RB,#%01000101· ; Place le port B en entrée/sortie
    ··mov· rb,#%00000010
    ··MOV·!RC,#%00000000· ; Place le port C en sortie
    ··setb·RD
    ;··CLR·RB
    ··CLR·fsr··; Efface la mémoire vive du SX
    :loop··SB·fsr.4
    ··SETB·fsr.3
    ··CLR·ind
    ··IJNZ·fsr,:loop
    main
    ··call·@read_USB
    ··mov·w,data
    ··and·w,#%00001111
    ··jmp·pc+w
    ··jmp·main··; si 0· le SX ne répond pas
    ··jmp·command

    command
    ; test réponse du SX28
    ··mov·w,#$0B
    ··call·@write_USB
    ··jmp·main


    ··org·$200
    ; **************************************************************************
    ; lecture de 8 bits sur le port USB par le SX
    ; **************************************************************************

    read_USB
    ;··clr·Sdata
    :att··snb·RXF··; rxf = 0, la FIFO est prête
    ··jmp·:att
    ··clrb·URD
    ··nop
    ··nop
    ··mov·data,ra··; lecture port a
    ··nop
    ··nop
    ··setb·URD
    :fin··retp

    ; **************************************************************************
    ; écriture sur le port 8 bits de l' USB
    ; **************************************************************************
    write_USB
    ··mov·data,w··; data sur le port B
    :att··snb·TXE··; si TXE = true, attente
    ··jmp·:att
    ··mov·temp,m··;
    ··mov·m,#$0F
    ··mov·!ra,#%0000··; ra en écriture
    ··mov·m,temp
    ··mov·ra,data··; data sur le port C
    ··nop
    ··nop
    ··nop
    ··setb·WR
    ··nop
    ··nop
    ··nop
    ··clrb·WR
    ··mov·temp,m
    ··mov·m,#$0F
    ··mov·!ra,#%1111··; ra en lecture
    ··mov·m,temp
    ··mov·data,#0
    ··retp
    end


    ·
Sign In or Register to comment.