In Electronic Infomation Category: C | on April 15,2011
A hardware circuit design STRONG> P>ALTERA CPLD is used this company EPM240T100, combined with serial communication MAX232 interface chip design, block diagram shown in Figure 1. P> Figure 1 CPLD serial communication module hardware design P> II, VHDL design and STAC9766T datasheet and description of program modules STRONG> P> Using VHDL on the CPLD programming, design three modules, the baud rate generator module, receivers, transmitters. P> 1. Baud Rate Generation Module STRONG> P> Baud rate generator is actually a divider, as mentioned earlier, the paper design of the baud rate of 19.2kb / s, designed to use the clock frequency of 10MHz, so the counter counts to 260 to turn when the count turn. P> Procedure is as follows (the key part of the reservation, non-essential part of the place by ... ...): P> ... ... P> ENTITY uart IS P> GENERIC (d_len: INTEGER: = 8); P> PORT ( P> F10MHz: IN STD_LOGIC; - the system clock P> Reset: IN STD_LOGIC; - reset signal P> Rxd: IN STD_LOGIC; - serial receiver P> Txd: OUT STD_LOGIC; - Serial transmission P> ); P> END uart; P> ARCHITECTURE behav of uart IS P> ... ... P> BEGIN P> Rxds <= rxd; P> PROCESS (f10MHz, reset) P> - Set the baud rate generator 19200kb / s P> VARIABLE clk19200hz: STD_LOGIC; P> VARIABLE count: INTEGER RANGE 0 TO 260; P> BEGIN P> IF reset = 0 THEN P> Count: = 0; P> Clk19200hz: = 0 ; P> ELSIF f10MHzEVENT AND f10MHz = 1 THEN P> IF count = 260 THEN P> Count: = 0; clk19200hz: = NOT clk19200hz; P> ELSE P> Count: = count +1; P> END IF; P> END IF; P> Baud_rate <= clk19200hz; P> END PROCESS; P> 2. Transmit module STRONG> P> T_state send some programming using the state machine, a total of two values: t-start and STAC9766T price and t_shift, respectively, start to send and STAC9766T suppliers and send hold. Reset button is pressed is set to t-start state, and transmit data bit is set to "1" bits of data sent count is 0, the t-start state, the state machine will be in this state and wait for the baud rate count rising edge of signal level. Rising edge arrives, according to the different values ??of the state to do t_state different treatment, if it is t-start start state is first read the data to be sent, and send start bit "0", and then send the state to maintain a t_shift state, sending remain t_shift state, continue to send the data to determine whether the full 8 bits, if the full state of the regression t-start, or continue to send, keep t_shift state, in order to avoid interference with the status of the remaining cases, automatically jump to the t- start state. Procedures are as follows: P> PROCESS (baud_rate, reset, data) P> - Data transmission part of the P> VARIABLE t_no: INTEGER RANGE 0 TO 8; P> - You send the data bit number P> VARIABLE txds: STD_LOGIC; P> VARIABLE dtmp: STD_LOGIC_VECTOR (7 P> DOWNTO 0); P> BEGIN P> IF reset = 0 THEN P> T_state <= t_start; P> Txds: = 1 ; P> T_no: = 0; P> ELSIF baud_rateevent AND baud_rate = 1 THEN P> CASE t_state IS P> WHEN t_start => P> Dtmp: = data; P> Txds: = 0 ; - Send Start P> T_state <= t_shift; P> WHEN t_shift => IF t_no = d_len THEN P> Txds: = 1 ; - Send end of the P> T_no: = 0; P> T_state <= t_start; P> ELSE P> Txds: = dtmp (t_no); - send a byte of data ??P> T_no: = t_no +1; P> END IF; P> WHEN thers => t_state <= t_start; P> END CASE; P> END IF; P> Txd <= txds; P> END PROCESS; P> 3. Data receiving module STRONG> P> State machine used to receive part of the program, a total of two states: P> R-start and start receiving r_shift and receiving, respectively, hold; reset button is pressed to set the r-start state and store the data received data to be assigned to "00000000" in the r-start status, receive state machine will be in this state and wait for the baud rate counter rising edge of signal level. Baud rate rising edge of the module count, based on the state to do different treatment of different values, if it is r-start the state is waiting to start receiving start signal, detected rxds = 0 start bit signal to maintain good reception to r_shift state, r_shift receiver will continue to hold the received data to determine whether the full 8 bits, if the full return of r-start the state, or continue to receive, maintain r_shift receiving hold, in order to avoid interference with the status of the remaining cases, automatically Jump to start receiving r-start state, a similar procedure and send the parts, here omitted. P> Three serial communication program VHDL simulation results STRONG> P>Serial Port Communication simulation results shown in Figure 2. It can be seen from the figure, each transmitted byte, or 8-bit data, the line will output a high level, then began to send the next byte. P> Similarly, the simulation waveform shows that the data reaches the receiver pin rxd effective before the line is held high until you receive a low start bit, after the start bit, 8-bit data serial receiver in order to save the results after the signal data received of you. P> Figure 2 Serial communication simulation waveforms P> Serial communication hardware verification STRONG> P> The program downloaded through the in-system programming of CPLD circuit board into the supporting hardware authentication, follow these steps. P> (1) determine the correspondence between pin: P> Serial receive pin rxd and 12 feet R1OUT corresponding max232; serial transmit pin txd and max232 corresponding to the 11 foot T1IN; reset button S1 and the corresponding reset signal. P> (2) conducted by the QUARTUS II pin assignment: P> F10MHz MAXII chip in the corresponding pin number 12; S1 chip in MAXII corresponding pin number 21; rxd MAXII chip in the corresponding pin number 89; txd MAXII chip in the corresponding control pin number is 90. P> (3) level defined: P> Button S1 is pressed the input signal is low. P> Application "serial debugging assistant" to verify the sending window, the characters need to send random input can be found by the PC, the character is sent to CPLD CPLD sent back and displayed in the receive window. Random data is sent in bulk after the analysis: the transmission 19.2kb / s transfer rate, error rate of 10-8. P>
P>
P>
About IcFull.com | Services | Contact Us | Links
All right reserved:icfull.com © 2010-2016 Certificate