Control de Interrupciones 8051

! " Control de interrupciones. Objetivos Recursos Necesarios ! • '( • " #$$ % )# )# Documentación a Entregar •

Views 119 Downloads 3 File size 967KB

Report DMCA / Copyright

DOWNLOAD FILE

Recommend stories

Citation preview

! "

Control de interrupciones.

Objetivos

Recursos Necesarios ! •

'(



" #$$ %

)#

)#

Documentación a Entregar •

# •

)



"*



"*! *



"*



)! "*

)

)

)

"

" "

) # • •

!

!

+

!

!

Plazo de Entrega •

,

-. -/ ! 0 ! 123 2 4 5 4 67 4 8 934 4:3 8 ; ;

1 "!

,G> ;

"!

%G>

;

%

%G%

;

%

C%G> ;

@

%

C%G% ;

@

% >

>G%

;

> >

C>G% ;

@

>

1 "! "!

"!

;

@

G%=

1

=

G%=

1 "!

>G>

C>G> ;

1

1

=

G%= 1 "!

"!

1

"!

=

G%=

1 "! "!

=

1

=

G%=

! :

! !

.

#

#include "uah_irq.h" #include void uah_enable_8051_irqs(void){ EA=1;

//Pone a 1 el Flag EA del registro IE

} void uah_disable_8051_irqs(void){ EA=0; //Pone a 0 el Flag EA del registro IE } void uah_mask_irqs(byte flags){ ... IE=...; } void uah_unmask_irqs(byte flags){ ... IE=...; }

2



;

23

3

34



;

23

3

34

# "+

!

" !

& '

+

" " !

2 7

+

!

"! "!



235 63 4

; !

1

=

!

B 00000 0 8 + 9 80

+

8 9 + !"

000 000 3+ 6 +

;

+

0 "< #$

80 :

"


; @

60

050! 0 :3 ;

+ A

? 3

+

"< •

23 5 63 4

;

1

=

!

235 63 4

!

"#

$

%& & '( )'! *+') % & '( )'*+') % % % % % # # # # %

& & & & &

! *+',- .'!/ ! *+',- .'/! 12* ! *+',- .'!/ ! *+',- .'/! 12* ! *+',- .'/5*5 "' "' "' "'

0 03 04 0 0

' ' 67# 89 ' ' 67# 89 : ' 67 : 89 : ' 67 : 89

& 8

+ #$

!

"# 6

"

;

&


"'

& : '6

"'

6 %-

'

' 6> "' ;$

'

' 6>

:

Control de la prioridad de las interrupciones 7

!

! ! I

/>?% @! + ;

/>?%

0 5 5

!

6 %) 3

+ 12

;

+ !

& '

&( )

>@ ;

+ ?

+ ;

@ ?

050

%) A

3 3+ 6 9 80 •

23 43 3

; !

83 9

+ !

=

23 43 3

"# # # #

A&

2 & 7

1

!

,

=

$

"' 6' ' "' 6' '

'"$"7 ' D7

"#

; "

"# 6 & ;

83202

&

6

& $89 & $89

&

#

=

!

"#

; C

#

> #

;

>

8

&$

;$

& $ ;$

6 ;

&$

void main (void) { byte i; byte flagPrioHighConfig[4]={0x14,0x3A,0x29,0x56}; byte flagPrioLowConfig[4]={0x1A,0x4F,0xD3,0xA2}; uah_disable_8051_irqs(); for(i=0;i 32

&( +(- / 5

+ %H

+

+

& 0

# $

1

%$

6 %H 4

32

:% :>

+ @

"!

+ + ;

! 6%

"

!

@ 4%

6>

4># 6 ,+

:%:>#6 "!

+ @ =, !

1 7 !

: %G> :2 % :

+

: %G% :2 % : : >G> :2 > :

+

: >G% :2 > :

19

,

, !

@ 32

+

23 43 3

+

35

!

... #define IRQ_EXT_INT_LEVEL_MODE

0

#define IRQ_EXT_INT_EDGE_MODE

1

int8 uah_irq_set_external_mode(uint8 irq_id, byte mode); ...

23 43 3 :>

35

+

:%

32

int8 uah_irq_set_external_mode(uint8 irq_id, byte mode){ int8 error=0; //NO HAY ERROR byte mask; if((irq_id!=ID_IRQ_INT0)&&(irq_id!=ID_IRQ_INT1)) error=-1; //error en el identificador else{ mask=(0x01)>8; //y asigna a P1 el byte alto de P1Val } } void fInt1 (void){ //IncremetP1Val P1Val++; P1=P1Val>>8; //Asigna a P1 el byte alto de P1Val } void main (void)

{

P1Val=0; P1=0; uah_disable_8051_irqs(); //Se enmascaran las interrupciones asociadas a los Timers y TXRX uah_mask_irqs(IRQ_FLAG_TIMER0|IRQ_FLAG_TIMER1|IRQ_FLAG_TXRX); //Se quita la máscara asociada a las interrupción de INT0 y INT1 uah_unmask_irqs(IRQ_FLAG_INT1|IRQ_FLAG_INT0); //Se configuran como de alta prioridad la interrupción de INT1 uah_irq_set_priority_high(IRQ_FLAG_INT1); //Se configuran como de baja prioridad el resto de interrupciones uah_irq_set_priority_low(IRQ_FLAG_INT0|IRQ_FLAG_TIMER0| IRQ_FLAG_TIMER1 |IRQ_FLAG_TXRX); //Instala la rutina de atención a la interrupción de INT0 uah_install_user_irq_handler(fInt0,ID_IRQ_INT0); //Instala la rutina de atención a la interrupción de INT1 uah_install_user_irq_handler(fInt1,ID_IRQ_INT1); // INT0 disparada por NIVEL uah_irq_set_external_mode(ID_IRQ_INT0, IRQ_EXT_INT_LEVEL_MODE); // INT1 disparada por NIVEL uah_irq_set_external_mode(ID_IRQ_INT1, IRQ_EXT_INT_LEVEL_MODE); uah_enable_8051_irqs(); while (1) {

/* Loop forever */

} }

21

2 &

"#

=

; "

6

# . 7# & $

"#

;$

6

;

# "#

7# & $

;$

38

#

;

38 ;

F

6'"

'5

;

6 ->

+

+

!

!

6 -%

!

! 22

+

A&

F &$ #

#

33

;

# !/ !/

#

=

'3

'6

>

#

>

=

0 C

2

; '3

&$

#

7& $

38

& '

6 --

6 -)

+

+

:2 > :2 %

$% 1 & # G& &

;$

&$ &

; #

0

;

&$