1. You can now buy finished microcontroller project from us, Check out the Store for the complete list of projects.
  2. Need a custom project, Send us some details about your project. So that we can quote the price for it.

ASM - Software Interrupt

Discussion in 'Microcontrollers' started by Cokaric, Feb 6, 2011.

  1. Cokaric

    Cokaric New Member

    Likes Received:
    Trophy Points:
    First of all I want to say hello to all the member here =)

    I am trying to learn more ASM on my own cause I can't get any good help from professors in my school.

    I have one problem I need to use interrupt in my newest program but I don't know how to use it cause no-one show us how does interrupt looks like in source code... We have been only learning theory...

    This is source code that I know it wont work >>

    Code (Text):
    1. START:
    2.     CALL OSMINKA_A4
    3.     CALL OSMINKA_A4S
    5. OSMINKA_A4:
    6.     MOV R3,#37h
    7. DEK1:
    8.     SETB P1.7
    9.     CALL NOTA_A4
    10.     CLR P1.7
    11.     CALL NOTA_A4
    12.     DJNZ R3, DEK1
    13.     RET
    15. OSMINKA_A4S:
    16.     MOV R3,#75h
    17. DEK2:
    18.     SETB P1.7
    19.     CALL NOTA_A4S
    20.     CLR P1.7
    21.     CALL NOTA_A4S
    22.     DJNZ R3, DEK2
    23.     RET
    25. NOTA_A4S:MOV R7,#0086H
    26. Z34:    MOV R6,#0004H
    27. Z33:    DJNZ R6,Z33
    28.     DJNZ R7,Z34
    29.     RET
    31. NOTA_A4:MOV R7,#008EH
    32. Z31:    MOV R6,#0004H
    33. Z32:    DJNZ R6,Z32
    34.     DJNZ R7,Z31
    35.     RET
    And this is my try to implement interrupt in it >>

    Code (Text):
    1. START:
    2.     JNB P1.0, START
    4.     CALL OSMINKA_A4
    5.     CALL OSMINKA_A4S
    7. OSMINKA_A4:
    8.     MOV R3,#37h
    9. DEK1:
    10.     SETB P1.7
    11.     [B]LJMP NOTA_A4[/B]
    12.     CLR P1.7
    13.     [B]LJMP NOTA_A4[/B]
    14.     DJNZ R3, DEK1
    15.     RET
    17. OSMINKA_A4S:
    18.     MOV R3,#75h
    19. DEK2:
    20.     SETB P1.7
    21.     [B]LJMP NOTA_A4S[/B]
    22.     CLR P1.7
    23.     [B]LJMP NOTA_A4S[/B]
    24.     DJNZ R3, DEK2
    25.     RET
    27. NOTA_A4S:MOV R7,#0086H
    28. Z34:    MOV R6,#0004H
    29. Z33:    DJNZ R6,Z33
    30.     DJNZ R7,Z34
    31.     [B]RETI[/B]
    33. NOTA_A4:MOV R7,#008EH
    34. Z31:    MOV R6,#0004H
    35. Z32:    DJNZ R6,Z32
    36.     DJNZ R7,Z31
    37.     [B]RETI[/B]
    But I don't know will this work cause, as I already said, never used interrupt in our source code.

    Hope some1 can help me with this =)

  2. Cokaric

    Cokaric New Member

    Likes Received:
    Trophy Points:

  3. Binu

    Binu Administrator

    Likes Received:
    Trophy Points:
    You should not jump into the interrupt routine with your code using the LJUMP.

    They program will jump into the interrupt automatically if an interrupt occurs. For this you need to enable the interrupt first, then an interrupt should be occurred.

    Just check here http://www.8052.com/tutint.phtml

Share This Page