Menu

A small defaut in this compilation : portx.pin = var.bit

brico31
2014-07-11
2014-07-12
  • brico31

    brico31 - 2014-07-11

    for example, this syntax :

    • the source syntax GCB : portc.2=var1.5 (var1 is a byte)

    • the compiler result :
      bcf PORTC,2 => here is the little problem, in first one the bit is always cleared
      btfsc VAR1,5
      bsf PORTC,2

    in first, the compiler, clear the bit.
    I think that it would be necessary to pass by a temporary variable then copy the result in the portx

    Have you a solution without modifying the compiler ?

    thinks
    best regards.

    Brico31

     
  • Chuck Hellebuyck

    More detail needed.
    What Device?
    What Compiler level are you using?

    You could create your own logic.
    if var1.5 = 1 then
    PORTC.2 = 1
    else
    PORTC.2 = 0
    end if

     
  • brico31

    brico31 - 2014-07-12

    hello,
    the compiler is the last version ;Program compiled by Great Cow BASIC (0.9 11/5/2014)
    the devices are 16F887 or F676 ..
    the problem exists sense i use GCB, (0.9 15/11/2009) compiler version.

    of course, between two variables it is not a problem but for port pin it s a glitch !

    ok for the logic test.

    brico31

     
  • Anobium

    Anobium - 2014-07-12

    Sorry, this is a limitation of GCB. It is the way GCBASIC addresses individual bits. On a PIC, it uses btfss, btfsc, bsf and bcf instructions, all of which require the individual bit to be hard coded. A workaround.

    ~~~~
    'Prepare a bit mask with only the correct bit set
    TempMask = 0
    Set C On
    Repeat var1
    Rotate TempMask Left
    End Repeat
    'set port OR you can OR with port bit to set as this... portc = portc OR TempMask
    portc = TempMask
    wait 100 ms

     
  • brico31

    brico31 - 2014-07-12

    ok for the limitation.
    I shall by-pass when it will be necessary.

    thank you.

     
  • Chuck Hellebuyck

    If the PORTC, 2 bit is set and the Var1, 5 is set then the i/o pin will see a glitch that drives it to ground very quickly. I've seen this cause issues in previous designs with other BASIC compilers so why can't a 'btfss' be added to the routine to test it before clearing the bit?

    btfss VAR1,5 <==== Why can't this be added?
    bcf PORTC,2
    btfsc VAR1,5
    bsf PORTC,2

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.