Simple Timer code in ATmega16 not outputting on OC0 pin in PROTEUS emulation software

Discussion in 'Embedded Systems and Microcontrollers' started by JPjuice23, Dec 8, 2014.

  1. JPjuice23

    Thread Starter New Member

    Mar 23, 2013
    1
    0
    This is the code,
    Code (Text):
    1. .org 0
    2. rjmp start
    3. .org $30
    4.  
    5. start:
    6. LDI r16, $04
    7. OUT SPH, r16
    8. LDI r16, $5F
    9. OUT SPL, r16
    10.  
    11. //setup
    12. cbi DDRB, 0
    13. sbi DDRB, 3
    14. ldi r20, 3
    15. out ocr0, r20
    16. ldi r20, 0
    17. out tcnt0, r20
    18. ldi r20, $56
    19. out tccr0, r20
    20.  
    21. here: rjmp here
    And this is a picture of the schematic, emulated on Proteus 8 Pro.

    [​IMG]

    I don't understand why the output at pin 4 is automatically high, when I set it up to only be high when the OCR0 meets the TCNT0, which goes up when I press the button. (CS = 110, means external pin is clock) It's high no matter what.

    Some more things, TCNT0 is $56, or 0101 0110
    CS is 110, meaning external clock PB0 is used
    WGM is 01, which is CTC, clear timer on compare match
    COM is 01, which will toggle on compare match.

    I don't understand if the problem is ME, my code, or the program. Thanks for your time.
     
  2. vishal12345

    New Member

    Dec 16, 2014
    8
    1
Loading...