Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
10/29/98 05:41
Read: times


 
#22 - Interrupt Problems
I'm trying to generate a 2 kHz pulse out of my Atmel 89C52.

I'm using the following code just to see if I can do it...

.ORG 0000h
LJMP MAIN

.ORG 001Bh
PUSH PSW
CPL P3.0 ;Toggle Port 3, Pin 0
LCALL COUNTER ;Reset Counter
POP PSW
RETI ;Return from Interrupt

.ORG 0040h
MAIN: SETB EA ;Turn on Interrupts
SETB ET1 ;Enable Timer 1
MOV P3, #H'00 ;Clear Port 3
LCALL COUNTER ;Start Counter
START: LJMP START

COUNTER: MOV TH1, #H'FE ;High Byte of 65119
MOV TL1, #H'5F ;Low Byte of 65119
MOV TMOD, #H'10 ;Put Timer 1 in 16-bit mode
SETB TF1 ;Make Time 1 start counting
RET

For some reason it toggles P3.0 at 20 kHz instead of 2 kHz. I can't figure it out.

Any help or suggestions would be greatly appreciated. I'm working on a class project and we want to use this to play tones on a speaker.

List of 2 messages in thread
TopicAuthorDate
Interrupt Problems            01/01/70 00:00      
RE: Interrupt Problems            01/01/70 00:00      

Back to Subject List