Interruption


Results 1 to 15 of 15

Thread: Interruption

Threaded View

  1. #6
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default

    An interrupt is overkill for this, and not the typical way to handle the problem at all.
    I'd use a counter to have your button checked every 10ms, and LED routine run every 500ms like this.
    and you get to save the interrupt for when it's actually needed.

    Code:
    x var byte
    direction var bit
    timerbyte var byte
    TRISA = 1
    TRISC = 0
    x = 1
    
    loop:
    PORTC = x
    pause 10
    timerbyte = timerbyte + 1
    
    IF PORTA.3 = 0 then
    IF direction = 0 THEN
    direction = 1
    ELSE
    direction = 0
    ENDIF ' direction
    ENDIF ' button
    
    IF timerbyte = 50 THEN timerbyte = 0 ' 500ms has passed if timerbyte = 0
    
    IF timerbyte = 0 THEN
    IF direction = 0 THEN
    	IF x = 8 THEN x = 1
    	x = x << 1
    ELSE
    	IF x = 1 THEN x = 8
    	x = x >> 1
    ENDIF ' direction
    ENDIF ' timerbyte
    
    goto loop
    Last edited by Art; - 30th December 2009 at 23:24.

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