Help with code


Closed Thread
Results 1 to 8 of 8

Thread: Help with code

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Question

    Thanks for the reply. Sorry it was a typing mistake @ vary
    This is not my full code. My actual code runs fine with reading port c.5 & Port B.

    My problem is correctly reading Port D.2 to D.7 into variable D. and if any of the pin is high, the buzzer should NOT toggle.
    But for some reason Variable D=0 is true even if Lets say PortD.2 or D.3 to D.7 is high i.e.=1

    I picked important lines from my code to explain the Problem.
    Is there any other way which can load PortD.2 to D.7 into variable D?
    ___________________
    WHY things get boring when they work just fine?

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Wink

    Ok

    so ...

    reading PORTD ...

    Code:
    		
    B=PortB : C=PortC.5
    
    D = PORTD & %11111100 ' read PORTD and mask port D.0 and D.1
    
    IF B=0 and C=0 and D=0 then
    		toggle BUZ: pause 20
    	endif
    should fit ... no indexing necessary !

    ( BTW ... not sure it was working so fine ... lol )

    Alain
    Last edited by Acetronics2; - 11th April 2010 at 10:27.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Thanks a lot. Problem solved.
    ___________________
    WHY things get boring when they work just fine?

  4. #4


    Did you find this post helpful? Yes | No

    Question 1 MOre Problem

    This time the problem is with 16F676. While compiling I get the following errors
    Code:
    ERROR: Unable to fit variable RM2_Save
    ERROR: Unable to fit variable RR1_Save
    ERROR: Unable to fit variable RR2_Save
    ERROR: Unable to fit variable RS1_Save
    ERROR: Unable to fit variable RS2_Save
    I am using DT-Interrupts in this code. Can some1 help me to get rid of these problems and what can I comment out in the ReEnterPBP or the other DT_INTS-14. Thanks
    ___________________
    WHY things get boring when they work just fine?

  5. #5


    Did you find this post helpful? Yes | No

    Question

    The only thing I am doing in the ISR is the following:
    Code:
    ToggleLEDF:
         If F1=1 then Toggle PortA.0
         If F2=1 then Toggle PortA.1
         If F3=1 then Toggle PortA.2
    @ INT_RETURN
    
    '---[TMR2 - interrupt handler]--------------------------------------------------
    ToggleLEDS:
         If S1=1 then Toggle PortA.0
         If S2=1 then Toggle PortA.1
         If S3=1 then Toggle PortA.2
    	pause 100
    @ INT_RETURN
    ___________________
    WHY things get boring when they work just fine?

  6. #6
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Wink too small a RAM !!!

    Sure 64 Bytes of SRAM is a bit weak to handle DT-Interrupts ....

    Try to spare (re-use ) 5 of your byte variables ... may be you can re-use B,C,D and two other temporary variables elsewhere in your Program ...

    @ first C can be declared as a BIT ... probably others too ...


    Or change for a Wider RAM Chip

    Or Ask Darrel for a "Fast Interrupt" Option saving only the " live " registers and letting you choose which variables really need to be saved ... such C " #pragma disablecontexsaving " directive ( I'd love such an option !!! )

    Alain
    Last edited by Acetronics2; - 11th April 2010 at 14:09.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

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