MC68HC11A8-Serial Communication
This project shows the serial communication using MC68HC11A8. To simulate circuit in this project, initially activate Mixed Mode simulator from the Schematic Editor window. Simulation can be performed by selecting Run Transient analysis (Oscillograph) or Analysis -> Transient Analysis from Simulation menu.
The circuit contains MC68HC11A8 microcontrollers, Seven Segment Display drivers–9368, and LED Display units. In the circuit, U1(MC68HC11A8) receives data transmitted from U2(MC68HC11A8). The data being received at U1 is converted from hex by a display decoder – 9368 to display information and then given to the display unit .
To simulate this functionality, U1 is configured as serial receiver and U2 as serial transmitter. The controller U2 is programmed to transmit hex code from 0x00 to 0xFF continuously.
At simulation time, U2 initiates transmission by placing a data on SCDR (SCI data register). The SCI module serially transmits this data through TX pin (PORT D 1), and sets TDRE bit (7th bit of SCSR) upon completion. When this flag is set, next data is placed in SCDR after clearing the flag bit. At U1, the data received at RX pin (PORT D 0) is stored in SCDR and sets RDRF bit (5th bit of SCSR) upon completion. When RDRF bit is set, the data in SCDR is transferred to Port B. Port B, which is an output port, is used to pass the received data to seven segment display decoder. The display decoders, at Port B convert this data to display information for seven segment display.
The display shows numbers from 00 to FF when simulated. Serial data at transmit line and equivalent parallel data at Port B can be observed in waveform viewer when simulation completes.
The source cThe source code written either in C or Assembly language can be viewed from the
code editor window.
The program is as shown:
Transmitter Transmitter Module:
#include "Test_PORTS.h"
char config[] __attribute__((section(".config"))) =
{
NOSEC | NOCOP | ROMON | EEON
};
int main()
{
uint8 temp = 0;
lock();
lock();
BAUD = 0x30; //Baud rate = 9600
SCCR2 = 0x08; //Transmit Enabled
DDRD |= 0x02;
DDRC = 0x00;
while (1)e="margin-left:15px">{
if (SCSR && 0if (SCSR && 0x80)
{
SCCR2 = 0x08;//Transmit Enabled
SCDR = temp;
temp = temp + 1;e="margin-left:25px">}
}
unlock();
return 0;
}
Receiver ModReceiver Module:
#include "Test_PORTS.h"
char config[] __attribute__((section(".config"))) =e="margin-left:20px">{
NOSEC | NOCOP | ROMON | EEON
};e="margin-left:15px">int main()
{
lock();
lock();
BAUD = 0x30;//Baud rate = 9600
SCCR2 = 0x06; //Receive enabled, Receive wakeup enabled
DDRD |= 0x02;
while (1)
{
{
SCCR2 = 0x06;//Receive enabled, Receive wakeup enabled
iif (SCSR && 0x20); //check for RDRF bit
PORTB = SCDR;
}p style="margin-left:20px"> unlock();
return 0;
}
The source code in the
code editor window
has to be
compiled
after making any modifications
(editing).
Also the code can be
debugged
during
simulation.