Documente Academic
Documente Profesional
Documente Cultură
NAME:
REGISTER NUMBER:
Exp. Date Name of the experiments Mark Sign
No.
SYLLABUS
OBJECTIVE:
a) Construct hardware design to interface switches and LEDs with parallel port of 8051
b) Write an assembly language program to interface switches and LEDs with parallel port of 8051
PROGRAM LOGIC:
Make port2 as input port and connect 8 switches in 8 pins of port2( P2.0 to P2.7)
Make port1 as output and 8 LEDs in 8 pins of port1 (P1.0 to P1.7)
Check status of individual switches by comparing values 01,02,04,08,10,20,40,80 in port2
If first switch is ON, then port 2 value is 01. Make first led to grow by sending value 01 in port1
Above step is repeated for all switch conditions and corresponding LED are made to grow.
PROGRAM CODE:
ORG 00H
MOV P2,#0FFH ;Input port to connect switches
MOV P1,#00H ;output port to connect LEDS
AGAIN: MOV A,P2
CJNE A,#01H, LOOP1 ;check first switch
MOV P1,#01H ;LED1 ON
LOOP1: CJNE A,#02H,LOOP2 ;check second switch
MOV P1,#02H ;LED2 ON
LOOP2: CJNE A,#04H,LOOP3 ;check third switch
MOV P1,#04H ;LED3 ON
LOOP3: CJNE A,#08H,LOOP4 ;check fourth switch
MOV P1,#08H ;LED4 ON
SJMP AGAIN
LOOP4: CJNE A,#10H,LOOP5 ;check FIFTH switch
MOV P1,#10H ;LED5 ON
SJMP AGAIN
LOOP5: CJNE A,#20H,LOOP6 ;check SIXTH switch
MOV P1,#20H ;LED6 ON
SJMP AGAIN
LOOP6: CJNE A,#40H,LOOP7 ;check SEVENTH switch
MOV P1,#40H ;LED7 ON
SJMP AGAIN
LOOP7: CJNE A,#80H,LOOP8 ;check EIGHTH switch
MOV P1,#80H ;LED8 ON
LOOP8: SJMP AGAIN
END
CIRCUIT DIAGRAM
RESULT:
Thus the hardware and software design are done for interfacing switches and LEDs with parallel port of 8051.
Ex.No.2 REAL TIME CLOCK USING SEGMENT DISPLAY Date :
OBJECTIVE:
a) Construct hardware design to display minute and second of real time clock through 7 segment display using
8051
b) Write an ALP to display minute and second information of real time clock in the 7 segment which is
interfaced with 8051
PROGRAM LOGIC:
Hex codes corresponds to numerical value 0 to 9 are stored in internal memory of 8051 as look up
table.
Program loop is created to show the count value from 0 to 9 in low digit 7segment display by sending
Data from LOOK UP table to port 2 of 8051
After 9th count, high digit 7 segment display count ( 0 to 5) is activated by sending corresponding data
from look up table to port 3 of 8051.
Data are taken from look up table for every 1 second delay and it is send to port s of 8051 in which 7
segment displays are connected.
PROGRAM CODE
LOOK UP TABLE
DIGIT HEX
CODE
0 3F
1 06
2 5B
3 4F
4 66
5 6D
6 7D
7 07
8 7F
9 67
7 SEGMENT DISPLAY
CIRCUIT DIAGRAM
RESULT:
Thus the hardware and software design are done for generating real time clock through 7 segment display using
8051.
Ex.No.3 8051 INTERFACE WITH PERSONAL COMPUTER Date :
OBJECTIVE:
PROGRAM LOGIC:
Timer is set for the baud rate of 9600 bit/sec .
Timer 1 is selected in auto reload mode by TMOD register by loading value of 20h.
Serial communication mode1 is selected as (8 bit, 1 stop bit, 1 start bit, REN enable) by SCON register.
ACC content is loaded with 00h value. Its value is incremented by one for predefined delay and it is send to
transmitter buffer.
Transmitted data are sends to COM port of PC through Max232 and RS232 connecting cable.
PROGRAM CODE
Label Program code Comment
ORG 0000H Starting at 00H location
MOV TMOD,#20H Select timer 1 in auto reload mode by
putting value 20H in TMOD
MOV TH1,#0FDH Select baut rate of 9600 bit/s by putting
value of FD in TH1 reg
MOV SCON,#50H Select UART in mode 1 by putting value of
50H in SCON reg
SETB TR1 Start timer1
MOV DPTR,#MYDATA Initialize DPTR with starting address of
string of characters
LOOP CLR A Clear ACC
MOVC A,@A+DPTR Get a character from location pointed by (
DPTR + A), put it into ACC
ACALL SEND Call subroutine SEND
INC DPTR Move to next location of string
JZ HERE
SJMP LOOP Continue LOOP
HERE SJMP HERE Stay in This loop HERE
WAIT JNB TI, WAIT Wait for transmission flag to raise for
checking completion of transmission
CLR TI Clear TI
RET Return from subroutine
CIRCUIT DIAGRAM
RS232 connection with microcontroller
PIN DIAGRAM
RESULT:
Thus the hardware and software designs are done to interface 8051 microcontroller with PC
Ex.No.4 LCD INTERFACE USING 8051 Date :
AIM:
a) Construct hardware design for interfacing LC D display with 8051
b) Write an ALP program to get input from port of 8051 and send to LCD which shows ASCII
equivalent character of input value.
PROGRAM LOGIC:
LCD display is configured for following characteristics i) LCD 2 lines, 5x7 matrix ii) Right
shift ( iii) Starting from first line.
Configuration of LCD is done by sending command word from 8051 to LCD
String to be displayed is stored in internal memory of 8051
Program loop is created to get input string stores in internal memory of 8051 and send it to LCD.
Strings of characters are treated as data word sent by 8051 to LCD.
Result:
Thus the hardware and software designs are done for interfacing LCD with 8051.
Ex.No.5 SINGLE CHANNEL DATA ACQUISITION SYSTEM USING 8051 Date :
OBJECTIVE:
a) Construct hardware design to interface analog to digital converter with 8051
b) Write an ALP to develop single channel data acquisition system in which input from sensor must be
converted into digital value. Output of sensor must be seen as LED grow which is connected in the port
of 8051
PROGRAM LOGIC:
PROGRAM CODE
Result:
Thus the hardware and software designs are done for developing single channel data acquisition system using
8051.
Ex.No.6 FIR HIGH PASS FILTER USING TMS320C6745 DSP Date :
Aim
To Implement the FIR High pass filter using TMS320C6745 KIT
Requirements
CCS v4
TMS320C6745 KIT
USB Cable
5V Adapter
Algorithm
1.First include the stdio.h file,math.h file,c6745.h file.spiadc.h file and spidac.h file.
8.Multiply the co-efficent values and adc values and store to the temp variables.
9.Then we add temp plus sum and move to the sum variables.
12.Finally adc values sent to spi write function and recover the original signal from dac.
Flowchart
START
A
Procedure
1. Open Code Composer Studio v4 .
2. In WorkSpace Launcher.
a. BROWSE Select the project location and make one new folder, MAKE NEW FOLDER Type
the Workspace name, OK OK.
3. FILE NEW CCS PROJECT
a. Project name: Type your project name.
b. Tick use default location. NEXT
c. Project type: C6000.
d. Tick Debug And Release. NEXT NEXT.
e. Output type: Executable.
f. Device Variant : generic C67XX Device.
g. Device Endianness : little
h. Code Generation Tools: TI v6.1.12.
i. Run time support library: automatic.
j. Tick Treat as an Assembly-only project.
k. Target content: none. FINISH
4. FILE NEW SOURCE FILE
a. Source file: Type your add.asm( .asm extension is must ).
b. Type the program.
c. FILE SAVE.
5. Paste the following board library files in workspace location.
a. Common folder (contains header files)
b. Gel folder (contains gel file)
c. Library folder(contains library files)
6. Paste the asm linker file and vectors.asm in the project location.(asm linker file and
vectors.asm is available in cd)
Note: Those folders and linker file are availble at cd.
7. PROJECT PROPERTIES C/C++ BUILD BASIC OPTION
a. Target processor version(--silicon version, -mv) : 6400+
b. IN C/C++ BUILD, INCLUDE OPTIONS (Add dir to #include search path(--include_path,-I))
select this add icon and add the following three path by indivdually
"${Diag}../../common/header"
"${XDAIS_CG_ROOT}/packages/ti/xdais"
"${C6000_CSL_CG_ROOT}/include"
8. FILE NEW TARGET CONFIGURATION FILE
a. file name: projectname. ccxml (.ccxml extension is must)
b. Connection: Texas Instrument XDS100 v1 USB Emulator.
c. Device: TMS320C6745. SAVE TARTGET CONFIGURATION C674X_0 BROWSE,
browse the workspace location, open the gel folder and select the GEL file. OPEN SAVE.
9. In C/C++ Project window, Right click the project REBUILD PROJECT.
10. Connections :
a. Connect the usb cable, in between PC to KIT.
b. Connect the 5v adapter and Power on the kit.
11. TARGET DEBUG ACTIVE PROJECT.(Then see out at corresponding place after run)
12.paste the following header file in the project location.
a.spiadc.h
b.spidac.h
13.Set the sine wave at 3v from function generator.
14.Connect the FG output to ADC connector(jp1).
15. Connect the DSO at DAC connector(j2).
16. TARGET RUN.
17. Output is displayed at DSO.
18. TARGET HALT.
FDA tool for filter co-efficient generation:
Magnitude specification
Wpass --- 1
Wstop --- 1
Generate c Header:
Targets --- Generate c Header
Copy the filter co-efficient and paste (float h[51]) in the program.
Program
#include <stdio.h>
#include <math.h>
#include "c6745.h"
#include "spiadc.h"
#include "spidac.h"
float h[51] ={
-0.01060591545,-0.004117832519,-0.004079894163,-0.003353076056,-0.001853102469,
0.0004065925605, 0.003321184311, 0.006660183426, 0.01010407601, 0.01322921738,
0.01557052694, 0.01663137041, 0.01597031951, 0.01320868172, 0.008123514242,
0.000646590197, -0.0090885479, -0.02072319016, -0.03375224397, -0.04746999219,
-0.06107512116, -0.07372291386, -0.08458722383, -0.09293565154, -0.09818658978,
0.900020659, -0.09818658978, -0.09293565154, -0.08458722383, -0.07372291386,
-0.06107512116, -0.04746999219, -0.03375224397, -0.02072319016, -0.0090885479,
0.000646590197, 0.008123514242, 0.01320868172, 0.01597031951, 0.01663137041,
0.01557052694, 0.01322921738, 0.01010407601, 0.006660183426, 0.003321184311,
0.0004065925605,-0.001853102469,-0.003353076056,-0.004079894163,-0.004117832519,
-0.01060591545
};
void main( void )
{
Uint8 spiadcbuf[3];
int i,xval[120],k;
float temp,sum;
C6745_init();
spiadc_init();
spidac_init();
for(i=0;i<52;i++)
{
xval[i]=0;
}
while(1)
{
spiadcbuf[0] = 0x01; // setup command
spiadcbuf[1] = 0xBF;
spiadcbuf[2] = 0x00;
xval[0] = adc_value;
sum = 0;
for(k=0;k<51;k++)
{
temp = (xval[k])*(h[k]);
sum = sum + temp;
}
SPI_Write(sum+1625);
for(i=50;i>=0;i--)
{
xval[i+1] = xval[i];
}
}
}
/****************************/
/* GLCD SPI Sent Data 8 bit */
/****************************/
void SPI_Write(unsigned short Data)
{
unsigned short receive;
DAC_CS_LOW();
Data = ( 0x3000 | Data );
/* Write 1 byte */
SPI0_SPIDAT0 = Data;
while((SPI0_SPIBUF & 0x20000000)==1);
/* Read 1 byte */
receive = SPI0_SPIBUF;
for(i=0;i<10;i++);
DAC_CS_HIGH();
}
Input
Output
Result
Thus, the FIR High pass filter was implemented and displayed the results in console window.
Ex.No.7 FFT 8 POINT DIT USING TMW320C6745 DSP Date :
Aim
To perform the 8 point FFT using DIT process from a given discrete sequence in TMS320C6745 KIT.
Requirements
CCS v 4
TMS320C6745 KIT
USB Cable
5V Adapter
ALGORITHM
3.Delare the address value of inputs and outputs.(Real value & imaginary).
Define PI 3.14159
A
PROCEDURE
0xC0001030 – 00000014
0xC0001034 – FFFFFFFB
0xC0001038 – 00000000
0xC000103C – 00000000
0xC0001040 – 00000000
0xC0001044 – 00000000
0xC0001048 – 00000000
0xC000104C – FFFFFFFB
PROGRAM
#include <math.h>
#define PI 3.14159
float x[8],t[8],s1[8],s2r[8],s2i[8],Xr[8],Xi[8],Yr[8],Yi[8];
W0i = 0,
W1r = 0.707,
W1i = -0.707,
W2r = 0,
W2i = -1,
W3r = -0.707,
W3i = -0.707;
void main()
int *Input,*Real_out,*Imag_out;
int i=0,j=0;
for(i=0;i<8;i++)
t[i] = 0;
x[0] = t[0];
x[1] = t[4];
x[2] = t[2];
x[3] = t[6];
x[4] = t[1];
x[5] = t[5];
x[6] = t[3];
x[7] = t[7];
s2i[0] = 0;
s2r[1] = s1[1];
s2i[2] = 0;
s2r[3] = s1[1];
s2i[4] = 0;
s2r[5] = s1[5];
s2i[6] = 0;
s2r[7] = s1[5];
j=0;
for(i=0;i<4;i++)
j++;
}
// complex subtraction for A - BWn
j=0;
for(i=4;i<8;i++)
j++;
Result
Thus, the 8 point FFT of given discrete sequence has performed and the result is stored at
memory location (0xC0001030 and 0xC0001050).
Ex.No.8(a) SWITCHES AND LED INTERFACE WITH ARM7 Date :
OBJECTIVE:
b) Write a ‘C’ language program to interface switches and LEDs with ARM7
PROGRAMLOGIC:
Select 8 pins of port1 from P1.24 to P1.31 as input pins by sending value ‘0’ to these pins
Connect 8 switches in the input pins.
Configure 8 pins of port1 from P1.16 to P1.23as output pins by writing value ‘1’ to these pins
Connect 8 LEDS in output pins.
Read status of the switches. If switch 1 is on , make LED1 ON else OFF
Repeat the above step for all switches and do corresponding changes in LED.
THEORY
GENERAL PURPOSE I/O
LPC2148 processor has two I/O ports, port0 and port1
Port 0 – P0.31 – P0.0 – 32 I/O lines
Port 1 – P1.31 – P1.16 – 16 I/O lines
Each pin out of the Microcontroller has several functions, maximum of 4 functions. In order to use the physical
pin out for a specific function, the pin is to be configured for that function. In order to Configure, it needs 2
bits (to carry out any one of 4 functions). For this purpose, there is a register called
PINSEL register.
PINSEL0, 32 bit register is used to configure Pin outs for P0.0 to P0.15 (16 pins), since each pin needs 2 bits.
PINSEL1 register is used to configure Pin outs for P0.16 to P0.31
PINSEL2 register is used to configure Pin outs for P1 Port, P1.16 to P1.31
After, configuring the pin as I/O line, next it is to be designated as input pin or output pin. It is done by another
register namely
IODIR.
IODIR0, 32 bit register is used to designate each I/O line in Port 0. Against the particular bit, if 1 is written,
then that bit in the Port 0 is designated as Output pin. If 0 is written in the particular bit position, then that I/O
pin will act as input pin.
Similarly, IODIR1, the bits 16 to 31 is used to designate the Port1 pins either as output or as input
If the pin is configured as output pin, in order to write 1 level in that pin, IOSET register is used. In
order to write 0 level in that pin, IOCLR register is used. It is to be noted that using single register IOSET
register, it is not possible to clear the bit.
IOSET0, 32 bit register is used to write 1 in any one of the output pin of Port0
IOCLR0, 32 bit register is used to write 0 in any one of the output pin of Port0
IOSET1, 32 bit register is used to write 1 in any one of the output pin of Port1
IOCLR1, 32 bit register is used to write 1 in any one of the output pin of Port1
If the pin is configured as input pin, in order to read the data from that pin, IOPIN register is used.
IOPIN0, 32 bit register is used to read the data from any one of the I/O pins of Port0.
IOPIN1, 32 bit register is used to read the data from any one of the I/O pins of Port1.
PROGRAM CODE
#include<lpc214x.h>
#define LED0 (1<<16)
#define LED1 (1<<17)
#define LED2 (1<<18)
#define LED3 (1<<19)
#define LED4 (1<<20)
#define LED5 (1<<21)
#define LED6 (1<<22)
#define LED7 (1<<23)
unsignedint SW_RD;
int main()
{
IODIR1 |= 0x00FF0000; // GPIO pins 16 to 23 configured as output
IODIR1 &= ~(0xFF000000); //All the other remaining GPIO pins configured as input
while(1)
{
SW_RD = ((IOPIN1 & 0xFF000000)>>24 & 0xFF);
RESULT:
Thus the hardware and software design are done for interfacing switches and LEDs with ARM7 processor.
Ex.No.8(b) LED INTERFACE WITH ARM7 PROCESSOR THROUGH Date :
TIMER CONTROL
OBJECTIVE:
a) Construct hardware design to interface LEDs with ARM7
b) Write a ‘C’ language program to interface LEDs with ARM7 through timer control.
PROGRAMLOGIC:
Configure 8 pins of port1 from P1.16 to P1.23as output pins by writing value ‘1’ to these pins
Connect 8 LEDS in output pins.
Timer 0 of ARM7 is configure to produce delay of 0.5 Second
Program loop is created to toggle LEDs connected in PORT1 for every 0.5 sec.
THEORY
TIMERS (Timer0 and Timer1) & SFR Regosters:
There are 2 nos. of 32 bit timers in this Microcontroller. Timer is basically a counter. For timer, internal clock
is given as input. Internally, PCLK, Peripheral clock is given as the input pulses.
Timer0 registers
TC0 – Timer Counter Register (32 bit register). For every clock pulse, this register is incremented.Before the
clock pulse is given to TCO, the clock pulses are given to the Prescale Counter namely
PC0 – 32 bit register. Along with PC0, there is another register namely Prescale Register PR0 – 32 bit register.
The PC0 gives one output pulse for each prescale register value. For example, if the PR0 has the value of
decimal 10, then the PC0 gives one output pulse for every 10 input clock pulses. The Prescale Counter output
is given as the clock pulse to Timer Counter register TC0. In this way, 32 bit Prescale divider is included in the
timer operation.
TCR0 – Timer Control Register. This register is used to reset the counter and disable/enable the Timer
Counter Register TC0.
T0MR0 – Match0 Register. It is a 32 bit register. The 32 bit content entered is compared with the content of
Timer/Counter Register TC0 continuously. When the match occurs, the following functions can be actuated.
1. If the interrupt enable bit is made 1, interrupt flag bit for MR0 is made 1 in T0IR register.
2. The Timer/Counter register can be made to reset.
3. The Timer/Counter register can be disabled.
4. In the corresponding pin MAT0.0 for MR0, output can be generated.
The first 3 functions can be actuated by writing control bits in MCR register – Match Control Register.
Similar to T0MR0, there are T0MR1, T0MR2, T0MR3 match registers. They can be also used for
comparing with the contents of Timer/Counter (TC) register. On match, the above functions for the
corresponding match register can be actuated.
T0IR – It is an 8 bit interrupt register. For every match, corresponding bit in this interrupt register is set. On
writing again the same bit in the Interrupt Service Routine, the corresponding bit will be cleared. Similar to
match registers, there are 4 capture registers namely T0CR0, T0CR1, T0CR2 and
T0CR3. The content of Timer/Counter (TC) register value is loaded into T0CR0, when an event on
physical pin CAP0.0, one particular physical input.
T0CCR is a 32 bit register which controls which edges of the capture inputs are used to load the Capture
registers and whether or not an interrupt is generated when a capture takes place. In order to use the timer as
counter, T0CTCR register is used. It is used to change to counter modeand to determine in which pin, physical
count input pulses is given.
PROGRAM CODE
#include <LPC214x.h>
#define DELAY_MS 1000 //0.5 Second(s) Delay
#define PRESCALE 60000 //60000 PCLK clock cycles to increment TC by 1
void Timer0_Init(void);
void Timer0_Run(void);
int main(void)
{
VPBDIV = 0x01; //PCLK=60Mhz
IO1DIR = 0x00FF0000; //P1.16 to P1.23 are output
Timer0_Init(); //Initialize Timer0
while(1)
{
Timer0_Run();
}
}
void Timer0_Init(void)
{
/*Assuming that PLL0 has been setup with CCLK = 60Mhz and PCLK also = 60Mhz.*/
T0CTCR = 0x0;
T0PR = PRESCALE-1; //(Value in Decimal!) - Increment T0TC at every
60000 clock cycles
//Count begins from zero hence subtracting 1
//60000 clock cycles @60Mhz = 1 mS
void Timer0_Run(void)
{
unsigned char regVal;
if(T0IR) //Polling the Interrupt Flag
{
regVal = T0IR; //R ead current IR value
IO1PIN ^= 0x00FF0000; // Toggle LED pins in Port 1
T0IR = regVal; // Write back to IR to clear Interrupt Flag
}
}
CIRCUIT DIAGRAM
RESULT:
Thus the hardware and software design are done for interfacing LEDs with ARM7 processor through timer
control.
Ex.No.9(a) UART INTERFACE WITH ARM7 Date :
OBJECTIVE:
a) Construct hardware design to interface PC with ARM7 through UART
b) Write a ‘C’ language program to display given string in PC through UART of ARM7.
PROGRAMLOGIC:
Configure UART of ARM7 in 9600 baut rate.
Program loop is created to send given string serially through transmitter pin of UART.
Hyper terminal of PC is configured in 9600 baut rate in COM port 1
Data transmitted through UART is received by receiver pin of COM port1 of PC.
Received string is displayed in hyper terminal’s editor.
THEORY
UART – Universal Asynchronous Receiver Transmitter (UART0 and UART1)
UART0 has lines TXD, RXD and Gnd lines for interfacing simple serial port.
UART1 has lines apart from the above, control lines for interfacing Modem also. Now, we are going to see
only the registers available in UART0
UART0 is used to send the byte of data serially and receive the byte of the data serially.
At the time of receiving, it receives the bits serially and assembles as parallel 8 bit data and it places in the
receiver buffer register U0RBR. It is the content of the top of the FIFO buffer registers.At the time of
transmitting, the user is supposed to place the 8 bit data in Transmit Hold Register Namely U0THR.
In serial communication, the serial data is sent in the same rate at which the receiving system also receives.
This is called baud rate (bits per second). For example, 9600 baud means 9600 bits per second.The internal
clock is divided by 16 bit no. to arrive at the required baud rate.
The Most Significant 8 bits of the divider value are stored is called U0DLM. The Least Significant 8 bits of
the divider value are stored in the register called U0DLL. At the time of writing in these registers only, DLAB
bit in the U0LCR register (Line Control Register) is to be made 1. Whenever, the U0THR register is empty, the
next byte of data can be sent to send it out serially. Similarly, whenever, a byte of data is received, it is placed
in U0RBR. As soon as it happen, interrupt may be raised to inform the user. But interrupts are to be enabled
before the use. There is an interrupt enable register namely U0IER. By writing proper bits in the register, the
above events will raise the interrupt.
There is another register U0IIR, which is used to find what are all the interrupts pending.The register FIFO
control register U0FCR is used to reset TX FIFO (Transmit First In First Out register set) and RX FIFO
(Receive First In First Out) and to enable them.
The register U0LCR, line control register is used to write serial protocol parameters namely, the word
length of the data, no. of stop bits, parity enable, parity select, Break control. The 7th bit in this register
namely DLAB is used to enter the 16 bit divisor data. Line Status register U0LSR is the status register to know
whether data has been received, data can be sent for transmission, to find out errors.There is another register
U0TER which is used to enable the serial transmitter
PROGRAM CODE
#include <LPC214x.H>
int main(void)
{
VPBDIV = 0x02; //Divide Pclk by two
UART0_Init(9600);
while(1)
{
UART0_PutS("\f*** Embedded Design LAB ***\n\n\r");
}
}
void UART0_PutC(char c)
{
while(!(U0LSR & 0x20)); // Wait until UART0 ready to send character
U0THR = c; // Send character
}
RESULT:
Thus the hardware and software design are done for interfacing PC with ARM7 processor through UART.
Ex.No.9(b) DAC INTERFACE WITH ARM7 Date :
OBJECTIVE:
a) Construct hardware design to interface DAC with ARM7.
b) Write a ‘C’ language program to generate sine wave through DAC of ARM7.
PROGRAMLOGIC:
Equation for generating sine wave is created.
Program loop is created to send Sine wave value (0 to 360 radian ) to DAC
DAC convert digital equivalent value of sine wave into analog signal
CRO is connected in DAC output pin (P0.25) to display sine wave.
PROGRAM CODE
/* Program to Generate Sine wave using on chip DAC */
#include <lpc214x.h>
#include <stdio.h>
#include <math.h>
intteta,DAC_In;
floatsine_val;
int main()
{
PINSEL1 = 0X00080000;
while(1)
{
for(teta=0;teta<360;teta++)
{
sine_val = (1.65 * sin(teta*Rad));
DAC_In = ((sine_val * 1024 /3.3)+512);
DACR = (DAC_In<<6);
}
}
}
CIRCUIT DIAGRAM
RESULT:
Thus the hardware and software design are done to generate sine wave through DAC of ARM7 processor.
Ex.No.9(c) ADC INTERFACE WITH ARM7 Date :
OBJECTIVE:
a) Construct hardware design to convert analog signal of sensor into digital value using ADC of ARM7.
b) Write a ‘C’ language program to convert analog signal of sensor into digital value in LED connected in port 1
PROGRAMLOGIC:
Configure 8 pins of port1 from P1.16 to P1.23 as output pins by writing value ‘1’ to these pins
Connect 8 LEDS in output pins.
Configure P0.30 as ADC In line.
Start analog to digital conversion and wait for conversion to end.
8 bit digital output of ADC is send into port1 (P1.16 to P1.23) where LEDS are connected.
LED grow patterns are observed as ADC result.
THEORY
Ato D Converter
There are 2 units of A/D Converters in this controller AD0 and AD1. There are 6 channels in AD0 unit and 8
channels in AD1 unit. It is a 10 bit ADC. The maximum analog voltage that can be given as input is 3.3V. It
uses Successive Approximation techniques to convert analog input to corresponding 10 bit digital output. It
requires clock which will be less than 4 MHz.
AD0CR register is a control register in which the details of the channel to be used, clock speed divider,
switching on the ADC Section and finally start signal to start the converter.
AD0GDR is the global data register. The done bit for the latest conversion and the 10 bit digital data are
available in this register.
AD0STAT is the A/D Status register. This register contains Done and error bits for all the channels for AD0
unit.
ADGSR is the global start register. It is used to start conversion in both A/D Converters AD0 and AD1
simultaneously.
AD0INTEN is A/D Interrupt Enable register. This register contain enable bits that allow the DONE flag of
each A/D Channel to raise common A/D interrupt.
PROGRAMCODE:
#include <lpc214x.h>
unsignedint ADC_OUT;
voidADC_LED_Init()
{
VPBDIV = 0x02; // clk division 60/2 = 30 Mhz
IODIR1 = 0x00FF0000; // P1.16 to P1.23 lines are Output LEDs
PINSEL1 |= (1<<28); // P0.30 config as ADC In line
AD0CR=0x00250608; // Cofig ADC Control Register
}
unsignedintADC_Convert()
{
AD0CR|=START; // ADC Start of Conversion
do
{
ADC_OUT = AD0GDR; // Read ADC value to variable
}
while ((ADC_OUT & DONE) == 0); // Wait for conversion Done
ADC_OUT = ADC_OUT<<8;
return ADC_OUT; // return the result
}
int main(void)
{
ADC_LED_Init();
while(1)
{
IO1PIN = ADC_Convert();
}
}
CIRCUIT DIAGRAM
RESULT:
Thus the hardware and software design are done to interface sensor with ADC of ARM7 processor.
Ex.No.10 GRAPHICAL LCD INTERFACE WITH ARM7 Date :
OBJECTIVE:
a) Construct hardware design to interface GLCD with ARM7.
b) Write a ‘C’ language program to display given picture in GLCD of ARM7.
Theory
The graphical LCD used in this experiment is Winstar’s WDG0151-TMI module, which is a 128×64 pixel
monochromatic display. It uses two Neotic display controller chips: NT7108C and NT7107C, which are
compatible with Samsung KS0108B and KS0107B controllers. The KS0108B (or NT7108C) is a dot matrix
LCD segment driver with 64 channel output, and therefore, the WDG0151 module contains two sets of it to
drive 128 segments. On the other hand, the KS0107B (or NT7107C) is a 64-channel common driver which
generates the timing signal to control the two KS0108B segment drivers. The KS0108B and KS0107B are very
popular controllers and have made their way into many graphical LCDs. The internal block diagram of the
WDG0151 GLCD module is shown below.
The NT1707C drives the 64 display lines, COM1 – COM64. The first NT7108C drives the left half segments
(SEG1 to SEG64) and the second one drives the right half segments (SEG65 to SEG128) of the display. The
two halves of the display can be individually accessed through the chip select pins (CS1 and CS2) of the two
NT7108C drivers. Each half consists of 8 horizontal pages (0-7) which are 8 bits (1 byte) high. This is
illustrated in the drawing below.
GLCD pages
Starting from page 0 on the left half (/CS1 = 0) if you transmit one data byte, it will appear on the first column
of page 0. If you repeat this 64 times, then switch to the second half, and repeat until 128th position is reached,
the first 8 display lines will be plotted. The next 8 lines can be plotted similarly by switching to page address 1.
The total amount of bytes needed for a complete display frame (128×64 pixels) is, therefore, 2 * 64 pixels * 8
bits = 1024 bytes.
PROGRAM CODE
#include <LPC214X.H>
#define CS2 0
#define CS1 1
#define RS 4
#define RW 5
#define EN 6
#define RST 7
extern const char PAN_LOGO[];
unsigned char D0;
unsigned char CMD[] = {0x3e,0xc0,0xb8,0x40,0x3f};
unsigned char i;
voidGLCD_Page(unsigned char);
voidGLCD_Cmd (unsigned long *, unsigned char, unsigned char);
voidGLCD_Data (unsigned long *, unsigned char, unsigned char);
voidGLCD_Draw (unsigned long *GLCDPort, unsigned char Datt, const char *Base);
void Delay();
// ------------------------------------------------------
// GLCD Picture name: phone.bmp
// GLCD Model: KS0108 128x64
// ------------------------------------------------------
int main()
{
PINSEL0 = 0;
PINSEL1 = 0;
IODIR0 = 0x0000FFFF;
while(1)
{
Delay(10);Delay(10);Delay(10);Delay(10);
GLCD_Draw(&IO0PIN, 8,PAN_LOGO);
}
GLCD_Page(1);
for(i=0;i<5;i++)
{
GLCD_Cmd(GLCDPort, D0, CMD[i]);
}
GLCD_Page(0);
for(i=0;i<5;i++)
{
GLCD_Cmd(GLCDPort, D0, CMD[i]);
}
D0 = Datt;
if(c & 0x80) IOSET0 = 1 << (D0+7); else IOCLR0 = 1 << (D0+7);
if(c & 0x40) IOSET0 = 1 << (D0+6); else IOCLR0 = 1 << (D0+6);
if(c & 0x20) IOSET0 = 1 << (D0+5); else IOCLR0 = 1 << (D0+5);
if(c & 0x10) IOSET0 = 1 << (D0+4); else IOCLR0 = 1 << (D0+4);
if(c & 0x08) IOSET0 = 1 << (D0+3); else IOCLR0 = 1 << (D0+3);
if(c & 0x04) IOSET0 = 1 << (D0+2); else IOCLR0 = 1 << (D0+2);
if(c & 0x02) IOSET0 = 1 << (D0+1); else IOCLR0 = 1 << (D0+1);
if(c & 0x01) IOSET0 = 1 << (D0); else IOCLR0 = 1 << (D0);
if(c & 0x80) IOSET0 = 1 << (D0+7); else IOCLR0 = 1 << (D0+7);
if(c & 0x40) IOSET0 = 1 << (D0+6); else IOCLR0 = 1 << (D0+6);
if(c & 0x20) IOSET0 = 1 << (D0+5); else IOCLR0 = 1 << (D0+5);
if(c & 0x10) IOSET0 = 1 << (D0+4); else IOCLR0 = 1 << (D0+4);
if(c & 0x08) IOSET0 = 1 << (D0+3); else IOCLR0 = 1 << (D0+3);
if(c & 0x04) IOSET0 = 1 << (D0+2); else IOCLR0 = 1 << (D0+2);
if(c & 0x02) IOSET0 = 1 << (D0+1); else IOCLR0 = 1 << (D0+1);
if(c & 0x01) IOSET0 = 1 << (D0); else IOCLR0 = 1 << (D0);
voidGLCD_Draw (unsigned long *GLCDPort, unsigned char Datt, const char *Base)
{
int Page, Column;
D0 = Datt;
}
}
}
void Delay()
{
unsignedinti,j;
for(i=0;i<25;i++)
for(j=0;j<200;j++);
}
CIRCUIT DIAGRAM
RESULT:
Thus the hardware and software design are done to display picture in GLCD of ARM7 processor.
EMBEDDED ‘C’ PROGRAM FOR INTERFACING EXPERIMENTS
LCD interface program
#include <reg51.h> /* define 8051 registers */
#include <stdio.h>
#include <string.h>
sbit rs = P0^4;
sbit rw = P0^5;
sbit en = P0^6;
void lcdcmd(unsigned char);
void MSDelay(unsigned int);
void lcddata(unsigned char);
void main(void)
{
unsigned char message[]="hello";
unsigned char z;
unsigned char x;
lcdcmd(0x38);
MSDelay(250);
lcdcmd(0x0E);
MSDelay(250);
lcdcmd(0x06);
MSDelay(250);
lcdcmd(0x84);
MSDelay(250);
while(1)
{
for(z=0;z<6;z++)
{
x = message[z];
lcddata(x);
}
}
}
void lcdcmd(unsigned char value)
{
P1 = value;
rs=0;
rw=0;
en=1;
MSDelay(1);
en=0;
return;
}
void lcddata(unsigned char value)
{
P1 = value;
rs=1;
rw=0;
en=1;
MSDelay(1);
en=0;
return;
}
void MSdelay(unsigned int itime)
{
unsigned int i,j;
for(i=0;i<itime;i++)
for(j=0;j<1275;j++);
return; }
REAL TIME CLOCK PROGRAM
#include <reg51.h> /* define 8051 registers */
#include <stdio.h>
#include <string.h>
void main(void)
{ unsigned char message[]= "Àù¤°™’‚ø€˜";
while(1)
{
unsigned int z;
unsigned char y;
unsigned char i;
P2=0xC0;
for(i=1;i<=6;i++)
{ for(y=0;y<10;y++)
{
P1 =message[y];
for(z=0;z<50000;z++);
}
P2=message[i];
}
}
}
PARALLEL PORT INTERFACE
#include<reg51.h>
#include<absacc.h>
void MSDelay(unsigned int itime);
void main()
{ unsigned char a;
XBYTE[0x4003]=0x90;
while(1)
{
a = XBYTE[0x4000];
MSDelay(100);
XBYTE[0x4001]= a;
MSDelay(100);
a=~a;
XBYTE[0x4002]=a;
MSDelay(100);
}
}
void MSDelay(unsigned int itime)
{
unsigned int i,j;
for(i=0;i<itime; i++)
for(j=0;j<1275;j++);
}
Single channel data acquisition system using 8051
#include <reg51.h> /* define 8051 registers */
#include <stdio.h>
sbit rd = P3^2;
sbit wr = P3^3;
sbit EOC =P3^4;
a. BROWSE Select the project location and make one new folder, MAKE NEW FOLDER
c. FILE SAVE.
I)) select this add icon and add the following three path by indivdually
"${Diag}../../common/header"
"${XDAIS_CG_ROOT}/packages/ti/xdais"
"${C6000_CSL_CG_ROOT}/include"
19. FILE NEW TARGET CONFIGURATION FILE
a. file name: projectname. ccxml (.ccxml extension is must)
b. Connection: Texas Instrument XDS100 v1 USB Emulator.
c. Device: TMS320C6745. SAVE TARTGET CONFIGURATION C674X_0 BROWSE,
browse the workspace location, open the gel folder and select the GEL file. OPEN
SAVE.
20. In C/C++ Project window, Right click the project REBUILD PROJECT.
21. Connections :
a. Connect the usb cable, in between PC to KIT.
b. Connect the 5v adapter and Power on the kit.
22. TARGET DEBUG ACTIVE PROJECT.(Then see out at corresponding place after run)
23. VIEW MEMORY
24. In right side, memory window will open. Type the output adrress 0xC0001000
25. TARGET RUN.
26. TARGET HALT.
See the Output at Particular location:
0xC0000000 – 99CE4C0B........
8051 and ARM Based VIVA Questions
8051 has an 8-bit data bus and an 8-bit ALU. This means it can transfer 8-bits in one cycle and also
operate on 8 bits in 1 cycle. Therefore 8051 is called an 8-bit microcontroller
4.Explain PC of 8051?
PC – Program Counter, is a 16-bit register. It contains address of the next instruction. It gets
incremented as soon as an instruction is fetched.