??? 10/14/04 13:54 Read: times |
#79311 - RE: DAC doesn\\\\\\\'t work well. Responding to: ???'s previous message |
Hiroaki,
There are the logical mistakes in your program. Your program executes only one part of your program depending on what it receives first: low byte or high one. The parts are very similar. Let's look at first one while(1) { if(RI) { P1^=0x02; daouth(SBUF); RI=0; } if(RI) { P1^=0x02; daoutl(SBUF); RI=0; } } Your program continuously checks RI twice in the endless loop. If RI(1)=1 that's OK, but if RI(1)=0 your program goes to check next RI2. If this RI(2)=1 it means that it received byte at this moment but it doesn't mean that it is the low byte you expected. The speed of your loop and your bitrate are not synchronized so obviously you have random results on the DAC-output. To solve this problem you have to rewrite both parts as following. P1^=0x02; while(1) { while(!RI) {} //waiting the high byte daouth(SBUF); //SBUF-->hiDAC RI=0; while(!RI) {} //waiting the low byte daoutl(SBUF); //SBUF-->loDAC RI=0; } Regards, George |
Topic | Author | Date |
DAC doesn't work well. | 01/01/70 00:00 | |
RE: DAC doesn't work well. | 01/01/70 00:00 | |
RE: DAC doesnt work well. | 01/01/70 00:00 | |
RE: DAC doesn't work well. | 01/01/70 00:00 | |
RE: DAC doesn\'t work well. | 01/01/70 00:00 | |
Serial transmission + output filter | 01/01/70 00:00 | |
RE: DAC doesn\\\'t work well. | 01/01/70 00:00 | |
RE: DAC doesn\\\\\\\'t work well.![]() | 01/01/70 00:00 |