+ Post New Thread
Results 1 to 3 of 3
  1. #1
    Newbie level 3
    Points: 498, Level: 4

    Join Date
    Apr 2013
    Posts
    3
    Helped
    0 / 0
    Points
    498
    Level
    4

    flash light with assembly

    Hi I want to create a flash light during 1 second using pic 16F877A
    I tried to do it with timer0 but it didn't work
    this is the source code:
    Code ASM - [expand]
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    
    list p=16f877a
              #include<p16f877a.inc>
              tmp EQU 0x020
           
     
              __CONFIG  _CP_OFF & _DEBUG_OFF & _WRT_OFF & _CPD_OFF & _LVP_OFF & _BODEN_OFF & _PWRTE_ON & _WDT_OFF & _HS_OSC
              
              BSF STATUS,RP0
              BCF STATUS,RP1
              MOVLW B'00000000'
              MOVWF TRISB
              BCF STATUS,RP0
              MOVLW B'00000000'
              MOVWF PORTB
     CONT     MOVLW B'11111111'
              MOVWF PORTB
              CALL TEMPO
              MOVLW B'00000000'
              MOVWF PORTB
              CALL TEMPO
              GOTO CONT
       ;programme de temporisation
    TEMPO     MOVLW D'255'
              MOVWF tmp
    CONT1     MOVLW D'255'
              MOVWF TMR0
              bcf INTCON,T0IF
    CONT2     btfss INTCON,T0IF
              GOTO CONT2
              decfsz tmp,f
              goto CONT1
              return
              END
    Last edited by FvM; 21st March 2015 at 20:15. Reason: Added syntax tags

    •   AltAdvertisement

        
       

  2. #2
    Super Moderator
    Points: 81,430, Level: 69
    Achievements:
    7 years registered
    Awards:
    2nd Helpful Member
    betwixt's Avatar
    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    13,349
    Helped
    4456 / 4456
    Points
    81,430
    Level
    69

    Re: flash light with assembly

    TMR0 counts UP and the next increment after 255 causes the interrupt. By setting it to 255 to start it interrupts almost immediately.

    The program would work better if you used an interrupt routine rather than just polling the interrupt flag.

    Brian.
    PLEASE - no friends requests or private emails, I simply don't have time to reply to them all.
    It's better to share your questions and answers on Edaboard so we can all benefit from each others experiences.



    •   AltAdvertisement

        
       

  3. #3
    Newbie level 3
    Points: 498, Level: 4

    Join Date
    Apr 2013
    Posts
    3
    Helped
    0 / 0
    Points
    498
    Level
    4

    Re: flash light with assembly

    Thanksssssssssssss



--[[ ]]--