Problem with Timer Interrupt, PortB5-7 gets disabled


Results 1 to 2 of 2

Threaded View

  1. #1

    Exclamation Problem with Timer Interrupt, PortB5-7 gets disabled

    Dear fellows, I'm trying to implement a timer which would get enabled on a specific action perfor a specific task ones the time is reached.

    I've achieved the timer thing using interrupts and breaking it down furthur and keeping a check on it. But achieving so i've came accross a number of problems

    1. Serin/Serout data started to messup...so used disable/enable before and after to run serial communication smoothly...

    2. Data read using names symbols on PortB failed so again disable/enable and used directly like PORTB instead of variable...this solved problem with Porb.0-Portb.4

    3. Now the actual problem being: I'm unable to deal with my inputs at Portb.5-Portb.7...

    I'm using 18F452 with a 4MHz XTAL

    The code for my interrupt and all is:


    '''''''''''''''''''''DEFINING and ENABLING INTERRUPT'''''''''''''''
    T0CON = %11000111
    INTCON = %00100000

    On Interrupt GoTo SwitchOff

    GoTo ProgramInitializationCont

    Disable
    SwitchOff:

    If CountIntTimer < TimerInSMS Then
    CountIntTimer = CountIntTimer + 1
    INTCON.2 = 0
    ElseIf CountIntTimer = TimerInSMS Then
    CountIntTimer = CountIntTimer + 1
    Power = 1 'Power Off
    Else
    Resume
    EndIf
    Resume
    Enable

    ''''''''''''''''''''''DEFINING and ENABLING INTERRUPT FINISHED'''''''''''''''


    TimeInSMS = 100

    ProgramInitializationCont:

    If PortA.0 = 1 then
    CountIntTimer = 0
    INTCON.2 = 0
    endif
    if PortB.7 = 1 then 'I'M NOT ABLE TO READ PORTB.5-7
    'Some other action
    endif

    end

    ''''''''''''''''''END OF CODE'''''''''''''''''''''''''''''''''

    An urgent solution in timers implementation and PortB reuse would be appreciated

    Best Regards
    JD

    PS: Although the code functions well on the OshonSoft PIC18 Simulator but am NOT ABLE TO READ MY PORTB IN PHYSICAL
    Last edited by jamshid.dastur; - 6th April 2010 at 18:53. Reason: forgot to mention simulation results

Members who have read this thread : 1

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts