
90 CHAPTER 8. SIGNAL GENERATION
REST
ADDD TOC2
STD TOC2 ; BUMP ALARM SETTING
; TURN OFF THE FLAG!
LDAA #%01000000
STAA TFLG1
RTI
; Connect the service to the interrupt ;
ORG $00DC ; $00DC WHERE THE SERVICE STARTS
JMP SERVICE ; JUMP TO WHERE THE SERVICE CODE ACTUALLY IS
Assemble and run the above program. Connect PA4 to an oscilloscope and verify
that the duty cycle and the frequency are correct.
8.5 Variable frequency generator
We now modify the above code to create a variable frequency generator. The
program will monitor the keyboard and depending on the number the user enters,
it will change the frequency as shown in the table below:
Number Frequency Period Period On time Off time
seconds ticks ticks ticks
0 440 0.002273 4545 1136 3409
1 466 0.002145 4290 1073 3217
2 494 0.002025 4050 1013 3037
3 523 0.001911 3822 956 2866
4 554 0.001804 3608 902 2706
5 587 0.001703 3405 851 2554
6 622 0.001607 3214 804 2410
7 659 0.001517 3034 759 2275
8 698 0.001432 2863 716 2147
9 740 0.001351 2703 676 2027
As a programmer we are only interested in the on-time and off-time. We use FDB
to create two tables in the data section as shown below:
ONTIMETBL
FDB 1136 ,1073, 1013, 956, 902
Kommentare zu diesen Handbüchern