We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
When I paste my Buzzer code in the main(), it works. But when I made a buzzer() to have this function execute in the main(), it didn't work. However,I want to use the buzzer function to execute in the main(). How? please help me!!
#pragma DEBUG OBJECTEXTEND CODE #pragma PL (60) #pragma PW (120) #define FOREVER 1 #include <89c51rd2.h> #include <stdio.h> void Delay(void); void Buzzer(void); sbit Buzer = P0^3; void Buzzer() { int i=0; P2=0x00; Buzer=0; while(i<6000) { TMOD=0x01; TH0=0x0D8; //if it is not flashing change it to 00 for TH0 and Tl0 TL0=0x0F0; TR0=1; while(TF0==0){} TR0=0; TF0=0; Buzer=~Buzer; i++; } } void main() { while (FOREVER) { Buzzer(); } }
I had suceeded. I used the step over the instruction of TF0 flag. I found it can't execute this line. then I switcthed the TF0 to test TF0==1. Of course it didn't work as well. But laterally when I switched it back, the timer starts beeping. I did it. Thank you, everyone!