Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[PIC] flash light with assembly

Status
Not open for further replies.

shoulay

Newbie level 3
Joined
Apr 10, 2013
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,298
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 a moderator:

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.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top