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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
11/12/04 13:11
Read: times


 
#81084 - RE: UART 9-Bits Mode Operation
Responding to: ???'s previous message
Thanks all. I changed operation of "flag" such like this and DAC no longer has problems.

flag = 0;

////////// DAC ROUTINE //////////
void dac(void) {
	if(RI) {
		a = SBUF;	// read from UART
		nine = RB8;
		RI = 0;

		if(nine) {	// receive HHHHLLLL
			high = (a&0xF0) >> 4;	// high: 0000HHHH
			low = (a&0x0F) << 4;	// low: LLLL0000
			flag = 1;
		}
		else if(flag) {	// receive LLLLHHHH
			low |= (a&0xF0) >> 4;	// low: LLLL0000 | 0000LLLL = LLLLLLLL
			DAC0H = high;	// output high 4bits
			DAC0L = low;	// output low 8bits			
			high = a&0x0F;	// high: 0000HHHH
			flag = 2;
		}
		else if(flag==2) {	// receive LLLLLLLL
			low = a;	// low: LLLLLLLL
			DAC0H = high;	// output high 4bits
			DAC0L = low;	// output low 8bits
			flag = 0;
		}
	}
}

+--------+--------+--------+--------+--------+--------+--------+--------+
|9th bit |    1   |    0   |    0   |    1   |    0   |    0   |        |
|data bit|HHHHLLLL|LLLLHHHH|LLLLLLLL|HHHHLLLL|LLLLHHHH|LLLLLLLL| repeat |
|flag    |    0   |    1   |    2   |    0   |    1   |    2   |        |
+--------+--------+--------+--------+--------+--------+--------+--------+

Remember the old rule: divide and conquer!

Big problems are made of lots of small problems - fix the small problems one by one and the big problem shall dissappear.


Yes, that right! I repeat that this is important really. This time I could know that again. Many thanks for those of you who kindly have helped me.

The next thing I have to do is to make transmission speed much faster. Though baud rate of this is set at 57600bps and sampling frequency should be 57600bps*(2data/33bits) = 3491Hz, it looks like possible input is 800Hz at most from the ocilloscope. This is quite a strange judging from a sampling theory. So, I know there're some point that makes transmission speed much lower than expected. I'll report the reason if I get it, or any comment is welcome in case I have additional problems. In fact I wish I could get the best performance of this system. Thank you very much.


List of 12 messages in thread
TopicAuthorDate
UART 9-Bits Mode Operation            01/01/70 00:00      
   RE: UART 9-Bits Mode Operation            01/01/70 00:00      
   RE: UART 9-Bits Mode Operation            01/01/70 00:00      
      RE: UART 9-Bits Mode Operation            01/01/70 00:00      
         RE: UART 9-Bits Mode Operation            01/01/70 00:00      
            RE: UART 9-Bits Mode Operation            01/01/70 00:00      
            RE: UART 9-Bits Mode Operation            01/01/70 00:00      
   RE: UART 9-Bits Mode Operation            01/01/70 00:00      
   RE: UART 9-Bits Mode Operation            01/01/70 00:00      
      RE: UART 9-Bits Mode Operation            01/01/70 00:00      
         RE: UART 9-Bits Mode Operation            01/01/70 00:00      
            RE: SPI vs UART 9-Bits Mode            01/01/70 00:00      

Back to Subject List