Menu

how to set SFR with inline assembly

2016-03-17
2016-03-17
  • Reginald Neale

    Reginald Neale - 2016-03-17

    I need to add code to a GCB 16F1829 program to change INLVLB so that the threshold for an input on RB7 is a schmitt trigger instead of the default TTL. I added this line at the beginning after the config bits

    bsf INLVLB,7

    It compiles and generates hex but doesn't seem to have any effect.
    The reason I need to do this is so that the current drain does not increase when the voltage on RB7 is neither HI or LO but wandering in between.

     
  • Anobium

    Anobium - 2016-03-17

    Just try INLVLB = 1

    No need for ASM.

     
  • Reginald Neale

    Reginald Neale - 2016-03-17

    Thanks Anobium. I'm using 16FLF1829, and PORTB only has bits 4-7. On INLVLB I only want bit 7 so that would be INLVLB = 128, right?
    The issue is that it's an input from a photocell, and when the voltage on that pin is for example, three quarters of the supply voltage, the power supply drain for the whole chip goes from a few uA to a hundred uA. Any opinion on whether this should be affected by setting the threshold level? I'm shooting for very low power, so I don't want to enable the analog stuff.

     
  • Anobium

    Anobium - 2016-03-17

    INLVLB7 is INLVLB bit 7. If you review the 16LF1829.dat file and search you will find the entry.

    So, INLVLB7 = 1 will set that value.

    I will leave the current usage question to more learned than me on that subject.

     
  • Reginald Neale

    Reginald Neale - 2016-03-17

    Thanks. I'll try that. I hope someone will chime in on current drain. I'm speculating that just because the chip recognizes the TTL or CMOS schmitt trigger levels for determining whether the input is Hi or LOW, that might not affect the pin's effect on current drain from the power supply for indeterminate levels.

     

Log in to post a comment.