microcontroller-111 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- microcontroller_111/__init__.py +4 -0
- microcontroller_111/core.py +25 -0
- microcontroller_111/data/01_8051_Timer_0_1_kHz_Square_Wave.txt +24 -0
- microcontroller_111/data/02_8051_Timer_1_500_Hz_and_1_kHz_Sequential.txt +47 -0
- microcontroller_111/data/03_8051_Hybrid_Waveform_400_Hz_900_Hz.txt +46 -0
- microcontroller_111/data/04_8051_UART_Transmit_Name.txt +45 -0
- microcontroller_111/data/05_8051_UART_Transmit_Name_and_Roll_Number.txt +45 -0
- microcontroller_111/data/06_PIC_Addition_of_Two_8_bit_Numbers.txt +17 -0
- microcontroller_111/data/07_PIC_Subtraction_of_Two_8_bit_Numbers.txt +23 -0
- microcontroller_111/data/08_PIC_Block_Data_Transfer.txt +33 -0
- microcontroller_111/data/09_PIC_Timer_Delay_LED_Toggle.txt +37 -0
- microcontroller_111/data/10_PIC_Up_Down_Counter_on_LEDs.txt +45 -0
- microcontroller_111/data/11_PIC_Start_Reset_8_bit_Up_Counter.txt +60 -0
- microcontroller_111/data/12_PIC_Shifting_LED_LSB_MSB.txt +63 -0
- microcontroller_111/data/13_PIC_LCD_Name_and_Roll_Number.txt +67 -0
- microcontroller_111/data/14_PIC_LCD_MICROCONTROLLER_LAB_ESE.txt +67 -0
- microcontroller_111/data/15_PIC_ADC_Threshold_LED_Control.txt +37 -0
- microcontroller_111/data/16_PIC_ADC_Display_Digital_Value.txt +61 -0
- microcontroller_111/data/17_PIC_LCD_Counter_00_99.txt +60 -0
- microcontroller_111/data/18_PIC_4x4_Keypad_Display_Key_on_LCD.txt +105 -0
- microcontroller_111/data/19_PIC_Keypad_Four_Successive_Keys.txt +119 -0
- microcontroller_111/data/20_PIC_Keypad_Digit_and_ASCII_Code.txt +118 -0
- microcontroller_111/data/21_PIC_Keypad_VALID_FUNCTION.txt +120 -0
- microcontroller_111/data/22_PIC_Stepper_Motor_Clockwise.txt +25 -0
- microcontroller_111/data/23_PIC_Stepper_Motor_Anticlockwise.txt +25 -0
- microcontroller_111/data/24_PIC_Stepper_Motor_Direction_by_Push_Buttons.txt +40 -0
- microcontroller_111/data/25_PIC_Stepper_Motor_One_Revolution_CW_then_CCW.txt +46 -0
- microcontroller_111/data/26_ARM_LPC2148_Addition_of_Two_32_bit_Numbers.txt +11 -0
- microcontroller_111/data/27_ARM_LPC2148_Subtraction_of_Two_32_bit_Numbers.txt +11 -0
- microcontroller_111/data/28_ARM_LPC2148_AND_OR_XOR_Operations.txt +14 -0
- microcontroller_111/data/29_ARM_LPC2148_7_Segment_Up_Counter_00_99.txt +41 -0
- microcontroller_111/data/30_ARM_LPC2148_7_Segment_Down_Counter_99_00.txt +41 -0
- microcontroller_111/data/31_ARM_LPC2148_7_Segment_Display_a_Two_Digit_Number.txt +35 -0
- microcontroller_111/data/32_ARM_LPC2148_7_Segment_Alternate_Patterns.txt +43 -0
- microcontroller_111/data/33_ARM_LPC2148_ADC_Value_on_Serial_Terminal.txt +39 -0
- microcontroller_111/data/34_ARM_LPC2148_ADC_Count_and_Voltage_on_Serial_Terminal.txt +37 -0
- microcontroller_111/data/35_ARM_LPC2148_ADC_Threshold_LOW_HIGH_on_Serial.txt +40 -0
- microcontroller_111/data/36_ARM_LPC2148_ADC_Count_and_Voltage_on_LCD.txt +77 -0
- microcontroller_111/data/37_ARM_LPC2148_RTC_Hours_Minutes_Seconds_on_LCD.txt +89 -0
- microcontroller_111/data/38_ARM_LPC2148_RTC_Date_and_Time_on_LCD.txt +96 -0
- microcontroller_111/data/39_ARM_LPC2148_RTC_Alarm_with_LED.txt +108 -0
- microcontroller_111/data/40_ARM_LPC2148_RTC_Time_with_LED_at_30_Seconds.txt +95 -0
- microcontroller_111-0.1.0.dist-info/METADATA +24 -0
- microcontroller_111-0.1.0.dist-info/RECORD +47 -0
- microcontroller_111-0.1.0.dist-info/WHEEL +5 -0
- microcontroller_111-0.1.0.dist-info/licenses/LICENSE +3 -0
- microcontroller_111-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#include <xc.h>
|
|
2
|
+
|
|
3
|
+
#define _XTAL_FREQ 20000000UL
|
|
4
|
+
|
|
5
|
+
unsigned char direction = 0; // 0 = stop, 1 = clockwise, 2 = anticlockwise
|
|
6
|
+
|
|
7
|
+
void main(void)
|
|
8
|
+
{
|
|
9
|
+
ADCON1 = 0x0F; // make pins digital
|
|
10
|
+
|
|
11
|
+
TRISC = 0x00; // PORTC = output (motor)
|
|
12
|
+
LATC = 0x00;
|
|
13
|
+
|
|
14
|
+
TRISAbits.TRISA2 = 1; // SW18 = input
|
|
15
|
+
TRISAbits.TRISA3 = 1; // SW19 = input
|
|
16
|
+
|
|
17
|
+
while(1)
|
|
18
|
+
{
|
|
19
|
+
if(PORTAbits.RA2 == 0) // SW18 pressed
|
|
20
|
+
direction = 1; // clockwise
|
|
21
|
+
|
|
22
|
+
if(PORTAbits.RA3 == 0) // SW19 pressed
|
|
23
|
+
direction = 2; // anticlockwise
|
|
24
|
+
|
|
25
|
+
if(direction == 1) // CLOCKWISE: 03 -> 06 -> 24 -> 21
|
|
26
|
+
{
|
|
27
|
+
LATC = 0x03; __delay_ms(5);
|
|
28
|
+
LATC = 0x06; __delay_ms(5);
|
|
29
|
+
LATC = 0x24; __delay_ms(5);
|
|
30
|
+
LATC = 0x21; __delay_ms(5);
|
|
31
|
+
}
|
|
32
|
+
else if(direction == 2) // ANTICLOCKWISE: 21 -> 24 -> 06 -> 03
|
|
33
|
+
{
|
|
34
|
+
LATC = 0x21; __delay_ms(5);
|
|
35
|
+
LATC = 0x24; __delay_ms(5);
|
|
36
|
+
LATC = 0x06; __delay_ms(5);
|
|
37
|
+
LATC = 0x03; __delay_ms(5);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#include <xc.h>
|
|
2
|
+
|
|
3
|
+
#define _XTAL_FREQ 20000000UL
|
|
4
|
+
|
|
5
|
+
#define STEPS_PER_REV 200 // 360 / 1.8 deg = 200 steps (change for your motor)
|
|
6
|
+
|
|
7
|
+
void Clockwise_1Rev(void)
|
|
8
|
+
{
|
|
9
|
+
unsigned int i;
|
|
10
|
+
for(i = 0; i < STEPS_PER_REV / 4; i++) // 4 steps per loop -> 50 loops
|
|
11
|
+
{
|
|
12
|
+
LATC = 0x03; __delay_ms(5);
|
|
13
|
+
LATC = 0x06; __delay_ms(5);
|
|
14
|
+
LATC = 0x24; __delay_ms(5);
|
|
15
|
+
LATC = 0x21; __delay_ms(5);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
void Anticlockwise_1Rev(void)
|
|
20
|
+
{
|
|
21
|
+
unsigned int i;
|
|
22
|
+
for(i = 0; i < STEPS_PER_REV / 4; i++)
|
|
23
|
+
{
|
|
24
|
+
LATC = 0x21; __delay_ms(5);
|
|
25
|
+
LATC = 0x24; __delay_ms(5);
|
|
26
|
+
LATC = 0x06; __delay_ms(5);
|
|
27
|
+
LATC = 0x03; __delay_ms(5);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
void main(void)
|
|
32
|
+
{
|
|
33
|
+
TRISC = 0x00; // PORTC = output (motor)
|
|
34
|
+
LATC = 0x00;
|
|
35
|
+
|
|
36
|
+
while(1)
|
|
37
|
+
{
|
|
38
|
+
Clockwise_1Rev(); // one revolution clockwise
|
|
39
|
+
LATC = 0x00; // coils OFF
|
|
40
|
+
__delay_ms(2000); // pause 2 s
|
|
41
|
+
|
|
42
|
+
Anticlockwise_1Rev(); // one revolution anticlockwise
|
|
43
|
+
LATC = 0x00; // coils OFF
|
|
44
|
+
__delay_ms(2000); // pause 2 s
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
AREA LOGIC, CODE, READONLY
|
|
2
|
+
ENTRY
|
|
3
|
+
|
|
4
|
+
START
|
|
5
|
+
LDR R0, =0x12345678 ; first 32-bit value
|
|
6
|
+
LDR R1, =0x0F0F0F0F ; second 32-bit value (mask)
|
|
7
|
+
|
|
8
|
+
AND R2, R0, R1 ; R2 = R0 AND R1
|
|
9
|
+
ORR R3, R0, R1 ; R3 = R0 OR R1
|
|
10
|
+
EOR R4, R0, R1 ; R4 = R0 XOR R1
|
|
11
|
+
|
|
12
|
+
STOP B STOP ; stay here (end of program)
|
|
13
|
+
|
|
14
|
+
END
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#include<LPC214X.h>
|
|
2
|
+
unsigned char seg[10] = {0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x90};
|
|
3
|
+
|
|
4
|
+
void delay(unsigned int x){
|
|
5
|
+
unsigned int i,j;
|
|
6
|
+
for(i = 0; i<x ; i++)
|
|
7
|
+
for(j = 0; j<1275 ; j++);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
int main(void)
|
|
11
|
+
{
|
|
12
|
+
|
|
13
|
+
unsigned int count, i;
|
|
14
|
+
PINSEL0 = 0x0000000; //P0.0 -> P0.15 as GPIO
|
|
15
|
+
PINSEL2 = 0x00000000; //P1.16 -> P1.31 as GPIO
|
|
16
|
+
IODIR0 = 0x00000C00;
|
|
17
|
+
IODIR1 = 0x00FF0000;
|
|
18
|
+
|
|
19
|
+
while(1)
|
|
20
|
+
{
|
|
21
|
+
|
|
22
|
+
for(count = 0; count<100; count++)
|
|
23
|
+
{
|
|
24
|
+
for(i = 0; i<50; i++){
|
|
25
|
+
|
|
26
|
+
IOCLR0 = 0x00000C00;
|
|
27
|
+
IOCLR1 = 0x00FF0000;
|
|
28
|
+
IOSET1 = seg[count/10] << 16;
|
|
29
|
+
IOSET0 = 0X00000400;
|
|
30
|
+
delay(20);
|
|
31
|
+
|
|
32
|
+
IOCLR0 = 0x00000C00;
|
|
33
|
+
IOCLR1 = 0x00FF0000;
|
|
34
|
+
IOSET1 = seg[count%10] << 16;
|
|
35
|
+
IOSET0 = 0X00000800;
|
|
36
|
+
delay(20);
|
|
37
|
+
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#include<LPC214X.h>
|
|
2
|
+
unsigned char seg[10] = {0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x90};
|
|
3
|
+
|
|
4
|
+
void delay(unsigned int x){
|
|
5
|
+
unsigned int i,j;
|
|
6
|
+
for(i = 0; i<x ; i++)
|
|
7
|
+
for(j = 0; j<1275 ; j++);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
int main(void)
|
|
11
|
+
{
|
|
12
|
+
int count;
|
|
13
|
+
unsigned int i;
|
|
14
|
+
PINSEL0 = 0x0000000; //P0.0 -> P0.15 as GPIO
|
|
15
|
+
PINSEL2 = 0x00000000; //P1.16 -> P1.31 as GPIO
|
|
16
|
+
IODIR0 = 0x00000C00;
|
|
17
|
+
IODIR1 = 0x00FF0000;
|
|
18
|
+
|
|
19
|
+
while(1)
|
|
20
|
+
{
|
|
21
|
+
|
|
22
|
+
for(count = 99; count>=0; count--)
|
|
23
|
+
{
|
|
24
|
+
for(i = 0; i<50; i++){
|
|
25
|
+
|
|
26
|
+
IOCLR0 = 0x00000C00;
|
|
27
|
+
IOCLR1 = 0x00FF0000;
|
|
28
|
+
IOSET1 = seg[count/10] << 16;
|
|
29
|
+
IOSET0 = 0X00000400;
|
|
30
|
+
delay(20);
|
|
31
|
+
|
|
32
|
+
IOCLR0 = 0x00000C00;
|
|
33
|
+
IOCLR1 = 0x00FF0000;
|
|
34
|
+
IOSET1 = seg[count%10] << 16;
|
|
35
|
+
IOSET0 = 0X00000800;
|
|
36
|
+
delay(20);
|
|
37
|
+
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#include<LPC214X.h>
|
|
2
|
+
unsigned char seg[10] = {0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x90};
|
|
3
|
+
|
|
4
|
+
void delay(unsigned int x){
|
|
5
|
+
unsigned int i,j;
|
|
6
|
+
for(i = 0; i<x ; i++)
|
|
7
|
+
for(j = 0; j<1275 ; j++);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
int main(void)
|
|
11
|
+
{
|
|
12
|
+
|
|
13
|
+
unsigned int num = 67;
|
|
14
|
+
PINSEL0 = 0x0000000; //P0.0 -> P0.15 as GPIO
|
|
15
|
+
PINSEL2 = 0x00000000; //P1.16 -> P1.31 as GPIO
|
|
16
|
+
IODIR0 = 0x00000C00;
|
|
17
|
+
IODIR1 = 0x00FF0000;
|
|
18
|
+
|
|
19
|
+
while(1)
|
|
20
|
+
{
|
|
21
|
+
|
|
22
|
+
IOCLR0 = 0x00000C00;
|
|
23
|
+
IOCLR1 = 0x00FF0000;
|
|
24
|
+
IOSET1 = seg[num/10] << 16;
|
|
25
|
+
IOSET0 = 0X00000400;
|
|
26
|
+
delay(20);
|
|
27
|
+
|
|
28
|
+
IOCLR0 = 0x00000C00;
|
|
29
|
+
IOCLR1 = 0x00FF0000;
|
|
30
|
+
IOSET1 = seg[num%10] << 16;
|
|
31
|
+
IOSET0 = 0X00000800;
|
|
32
|
+
delay(20);
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#include <LPC214X.H>
|
|
2
|
+
|
|
3
|
+
unsigned char seg[10] = {0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x90};
|
|
4
|
+
|
|
5
|
+
void delay(unsigned int x)
|
|
6
|
+
{
|
|
7
|
+
unsigned int i, j;
|
|
8
|
+
for(i = 0; i < x; i++)
|
|
9
|
+
for(j = 0; j < 1275; j++);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
void show(unsigned char left, unsigned char right, unsigned int t)
|
|
13
|
+
{
|
|
14
|
+
unsigned int i;
|
|
15
|
+
for(i = 0; i < t; i++)
|
|
16
|
+
{
|
|
17
|
+
IOCLR0 = 0x00000C00;
|
|
18
|
+
IOCLR1 = 0x00FF0000;
|
|
19
|
+
IOSET1 = left << 16;
|
|
20
|
+
IOSET0 = 0x00000400;
|
|
21
|
+
delay(5);
|
|
22
|
+
|
|
23
|
+
IOCLR0 = 0x00000C00;
|
|
24
|
+
IOCLR1 = 0x00FF0000;
|
|
25
|
+
IOSET1 = right << 16;
|
|
26
|
+
IOSET0 = 0x00000800;
|
|
27
|
+
delay(5);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
int main(void)
|
|
32
|
+
{
|
|
33
|
+
PINSEL0 = 0x00000000;
|
|
34
|
+
PINSEL2 = 0x00000000;
|
|
35
|
+
IODIR0 = 0x00000C00;
|
|
36
|
+
IODIR1 = 0x00FF0000;
|
|
37
|
+
|
|
38
|
+
while(1)
|
|
39
|
+
{
|
|
40
|
+
show(seg[1], seg[2], 100);
|
|
41
|
+
show(0x89, 0xF9, 100);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#include <lpc214x.h>
|
|
2
|
+
#include <stdio.h>
|
|
3
|
+
|
|
4
|
+
int j;
|
|
5
|
+
char charArray[5];
|
|
6
|
+
void delay(unsigned int i)
|
|
7
|
+
{
|
|
8
|
+
int j,k;
|
|
9
|
+
for(j=0;j<i;j++)
|
|
10
|
+
for(k=0;k<1275;k++);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
int main()
|
|
14
|
+
{
|
|
15
|
+
char a;
|
|
16
|
+
unsigned int adc;
|
|
17
|
+
PINSEL2 = 0;
|
|
18
|
+
PINSEL1 = (1U << 24);
|
|
19
|
+
AD0CR = (1U << 1) | (3U << 8) | (1U << 21);
|
|
20
|
+
PINSEL0=0X00000005 ; //Configuring p0.0 and p0.1 for serial communication
|
|
21
|
+
U0LCR = 0X83;// make DLAB 1 for setting baud rate
|
|
22
|
+
U0DLM=0X00;
|
|
23
|
+
U0DLL=0X61; //setting for making baud rate 9600
|
|
24
|
+
U0LCR=0X03; //making DLAB 0 for serial communication
|
|
25
|
+
while(1)
|
|
26
|
+
{
|
|
27
|
+
AD0CR |= (1U << 24); // start conversion
|
|
28
|
+
while((AD0GDR & (1U << 31)) == 0);
|
|
29
|
+
adc = (AD0GDR >> 6) & 0x3FF;
|
|
30
|
+
sprintf(charArray, "%d", adc);
|
|
31
|
+
for(j = 0; j < 5; j++){
|
|
32
|
+
U0THR = charArray[j];
|
|
33
|
+
delay(500);
|
|
34
|
+
}
|
|
35
|
+
U0THR = ' ';
|
|
36
|
+
delay(500);
|
|
37
|
+
while(!(U0LSR &0X40)); //checking whether transmitted buffer is empty
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#include <lpc214x.h>
|
|
2
|
+
#include <stdio.h>
|
|
3
|
+
|
|
4
|
+
int j;
|
|
5
|
+
char charArray[30];
|
|
6
|
+
void delay(unsigned int i)
|
|
7
|
+
{
|
|
8
|
+
int j,k;
|
|
9
|
+
for(j=0;j<i;j++)
|
|
10
|
+
for(k=0;k<1275;k++);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
int main()
|
|
14
|
+
{
|
|
15
|
+
unsigned int adc, mv;
|
|
16
|
+
PINSEL2 = 0;
|
|
17
|
+
PINSEL1 = (1U << 24);
|
|
18
|
+
AD0CR = (1U << 1) | (3U << 8) | (1U << 21);
|
|
19
|
+
PINSEL0=0X00000005 ;
|
|
20
|
+
U0LCR = 0X83;
|
|
21
|
+
U0DLM=0X00;
|
|
22
|
+
U0DLL=0X61;
|
|
23
|
+
U0LCR=0X03;
|
|
24
|
+
while(1)
|
|
25
|
+
{
|
|
26
|
+
AD0CR |= (1U << 24);
|
|
27
|
+
while((AD0GDR & (1U << 31)) == 0);
|
|
28
|
+
adc = (AD0GDR >> 6) & 0x3FF;
|
|
29
|
+
mv = (adc * 3300) / 1023;
|
|
30
|
+
sprintf(charArray, "ADC=%d V=%d.%03dV\r\n", adc, mv/1000, mv%1000);
|
|
31
|
+
for(j = 0; charArray[j] != '\0'; j++){
|
|
32
|
+
while(!(U0LSR & 0x20));
|
|
33
|
+
U0THR = charArray[j];
|
|
34
|
+
}
|
|
35
|
+
delay(500);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#include <lpc214x.h>
|
|
2
|
+
#include <stdio.h>
|
|
3
|
+
|
|
4
|
+
int j;
|
|
5
|
+
char charArray[30];
|
|
6
|
+
void delay(unsigned int i)
|
|
7
|
+
{
|
|
8
|
+
int j,k;
|
|
9
|
+
for(j=0;j<i;j++)
|
|
10
|
+
for(k=0;k<1275;k++);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
int main()
|
|
14
|
+
{
|
|
15
|
+
unsigned int adc;
|
|
16
|
+
unsigned int threshold = 512;
|
|
17
|
+
PINSEL2 = 0;
|
|
18
|
+
PINSEL1 = (1U << 24);
|
|
19
|
+
AD0CR = (1U << 1) | (3U << 8) | (1U << 21);
|
|
20
|
+
PINSEL0=0X00000005 ;
|
|
21
|
+
U0LCR = 0X83;
|
|
22
|
+
U0DLM=0X00;
|
|
23
|
+
U0DLL=0X61;
|
|
24
|
+
U0LCR=0X03;
|
|
25
|
+
while(1)
|
|
26
|
+
{
|
|
27
|
+
AD0CR |= (1U << 24);
|
|
28
|
+
while((AD0GDR & (1U << 31)) == 0);
|
|
29
|
+
adc = (AD0GDR >> 6) & 0x3FF;
|
|
30
|
+
if(adc < threshold)
|
|
31
|
+
sprintf(charArray, "ADC=%d LOW\r\n", adc);
|
|
32
|
+
else
|
|
33
|
+
sprintf(charArray, "ADC=%d HIGH\r\n", adc);
|
|
34
|
+
for(j = 0; charArray[j] != '\0'; j++){
|
|
35
|
+
while(!(U0LSR & 0x20));
|
|
36
|
+
U0THR = charArray[j];
|
|
37
|
+
}
|
|
38
|
+
delay(500);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#include <lpc214x.h>
|
|
2
|
+
#include <stdio.h>
|
|
3
|
+
|
|
4
|
+
char charArray[20];
|
|
5
|
+
|
|
6
|
+
void delay(unsigned int i)
|
|
7
|
+
{
|
|
8
|
+
int j,k;
|
|
9
|
+
for(j=0;j<i;j++)
|
|
10
|
+
for(k=0;k<1275;k++);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
void lcd_cmd(unsigned char c)
|
|
14
|
+
{
|
|
15
|
+
IOCLR0 = 0x00100800;
|
|
16
|
+
IOCLR1 = 0x00FF0000;
|
|
17
|
+
IOSET1 = c << 16;
|
|
18
|
+
IOSET0 = 0x00000400;
|
|
19
|
+
delay(2);
|
|
20
|
+
IOCLR0 = 0x00000400;
|
|
21
|
+
delay(2);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
void lcd_dat(unsigned char d)
|
|
25
|
+
{
|
|
26
|
+
IOSET0 = 0x00000800;
|
|
27
|
+
IOCLR0 = 0x00100000;
|
|
28
|
+
IOCLR1 = 0x00FF0000;
|
|
29
|
+
IOSET1 = d << 16;
|
|
30
|
+
IOSET0 = 0x00000400;
|
|
31
|
+
delay(2);
|
|
32
|
+
IOCLR0 = 0x00000400;
|
|
33
|
+
delay(2);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
void lcd_str(char *s)
|
|
37
|
+
{
|
|
38
|
+
while(*s)
|
|
39
|
+
lcd_dat(*s++);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
int main()
|
|
43
|
+
{
|
|
44
|
+
unsigned int adc, mv;
|
|
45
|
+
PINSEL0 = 0;
|
|
46
|
+
PINSEL2 = 0;
|
|
47
|
+
PINSEL1 = (1U << 24);
|
|
48
|
+
AD0CR = (1U << 1) | (3U << 8) | (1U << 21);
|
|
49
|
+
|
|
50
|
+
IODIR0 = 0x00100C00;
|
|
51
|
+
IODIR1 = 0x00FF0000;
|
|
52
|
+
|
|
53
|
+
delay(20);
|
|
54
|
+
lcd_cmd(0x38);
|
|
55
|
+
lcd_cmd(0x0C);
|
|
56
|
+
lcd_cmd(0x06);
|
|
57
|
+
lcd_cmd(0x01);
|
|
58
|
+
delay(20);
|
|
59
|
+
|
|
60
|
+
while(1)
|
|
61
|
+
{
|
|
62
|
+
AD0CR |= (1U << 24);
|
|
63
|
+
while((AD0GDR & (1U << 31)) == 0);
|
|
64
|
+
adc = (AD0GDR >> 6) & 0x3FF;
|
|
65
|
+
mv = (adc * 3300) / 1023;
|
|
66
|
+
|
|
67
|
+
sprintf(charArray, "ADC = %4d", adc);
|
|
68
|
+
lcd_cmd(0x80);
|
|
69
|
+
lcd_str(charArray);
|
|
70
|
+
|
|
71
|
+
sprintf(charArray, "V = %d.%03dV", mv/1000, mv%1000);
|
|
72
|
+
lcd_cmd(0xC0);
|
|
73
|
+
lcd_str(charArray);
|
|
74
|
+
|
|
75
|
+
delay(300);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
#include <lpc214x.h>
|
|
2
|
+
#include <stdio.h>
|
|
3
|
+
|
|
4
|
+
char str[20];
|
|
5
|
+
|
|
6
|
+
void delay(unsigned int x)
|
|
7
|
+
{
|
|
8
|
+
unsigned int i, j;
|
|
9
|
+
for(i = 0; i < x; i++)
|
|
10
|
+
for(j = 0; j < 10; j++);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
void cmd(unsigned char a)
|
|
14
|
+
{
|
|
15
|
+
IOCLR0 = 0x00100800;
|
|
16
|
+
IOCLR1 = 0x00FF0000;
|
|
17
|
+
IOSET1 = a << 16;
|
|
18
|
+
IOSET0 = 0x00000400;
|
|
19
|
+
delay(10);
|
|
20
|
+
IOCLR0 = 0x00000400;
|
|
21
|
+
delay(100);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
void dat(unsigned char a)
|
|
25
|
+
{
|
|
26
|
+
IOSET0 = 0x00000800;
|
|
27
|
+
IOCLR0 = 0x00100000;
|
|
28
|
+
IOCLR1 = 0x00FF0000;
|
|
29
|
+
IOSET1 = a << 16;
|
|
30
|
+
IOSET0 = 0x00000400;
|
|
31
|
+
delay(10);
|
|
32
|
+
IOCLR0 = 0x00000400;
|
|
33
|
+
delay(100);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
void show(char *p)
|
|
37
|
+
{
|
|
38
|
+
while(*p)
|
|
39
|
+
dat(*p++);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
int main(void)
|
|
43
|
+
{
|
|
44
|
+
unsigned int i;
|
|
45
|
+
PLL0CON = 0x00;
|
|
46
|
+
PLL0FEED = 0xAA;
|
|
47
|
+
PLL0FEED = 0x55;
|
|
48
|
+
VPBDIV = 0x01;
|
|
49
|
+
|
|
50
|
+
PINSEL0 = 0x00000000;
|
|
51
|
+
PINSEL2 = 0x00000000;
|
|
52
|
+
|
|
53
|
+
IODIR0 = 0x00100C00;
|
|
54
|
+
IODIR1 = 0x00FF0000;
|
|
55
|
+
|
|
56
|
+
IOCLR0 = 0x00100C00;
|
|
57
|
+
IOCLR1 = 0x00FF0000;
|
|
58
|
+
|
|
59
|
+
delay(2000);
|
|
60
|
+
cmd(0x38);
|
|
61
|
+
cmd(0x0C);
|
|
62
|
+
cmd(0x06);
|
|
63
|
+
cmd(0x01);
|
|
64
|
+
delay(20000);
|
|
65
|
+
|
|
66
|
+
CCR = 0x02;
|
|
67
|
+
CCR = 0x00;
|
|
68
|
+
|
|
69
|
+
SEC = 0;
|
|
70
|
+
MIN = 9;
|
|
71
|
+
HOUR = 10;
|
|
72
|
+
|
|
73
|
+
PREINT = 365;
|
|
74
|
+
PREFRAC = 6912;
|
|
75
|
+
|
|
76
|
+
CCR = 0x01;
|
|
77
|
+
|
|
78
|
+
cmd(0x80);
|
|
79
|
+
show("Current Time");
|
|
80
|
+
|
|
81
|
+
while(1)
|
|
82
|
+
{
|
|
83
|
+
sprintf(str, "%02d:%02d:%02d", HOUR, MIN, SEC);
|
|
84
|
+
cmd(0xC4);
|
|
85
|
+
show(str);
|
|
86
|
+
|
|
87
|
+
for(i = 0; i < 1000; i++);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
#include <lpc214x.h>
|
|
2
|
+
#include <stdio.h>
|
|
3
|
+
|
|
4
|
+
char str[20];
|
|
5
|
+
char *days[7] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
|
|
6
|
+
|
|
7
|
+
void delay(unsigned int x)
|
|
8
|
+
{
|
|
9
|
+
unsigned int i, j;
|
|
10
|
+
for(i = 0; i < x; i++)
|
|
11
|
+
for(j = 0; j < 10; j++);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
void cmd(unsigned char a)
|
|
15
|
+
{
|
|
16
|
+
IOCLR0 = 0x00100800;
|
|
17
|
+
IOCLR1 = 0x00FF0000;
|
|
18
|
+
IOSET1 = a << 16;
|
|
19
|
+
IOSET0 = 0x00000400;
|
|
20
|
+
delay(10);
|
|
21
|
+
IOCLR0 = 0x00000400;
|
|
22
|
+
delay(100);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
void dat(unsigned char a)
|
|
26
|
+
{
|
|
27
|
+
IOSET0 = 0x00000800;
|
|
28
|
+
IOCLR0 = 0x00100000;
|
|
29
|
+
IOCLR1 = 0x00FF0000;
|
|
30
|
+
IOSET1 = a << 16;
|
|
31
|
+
IOSET0 = 0x00000400;
|
|
32
|
+
delay(10);
|
|
33
|
+
IOCLR0 = 0x00000400;
|
|
34
|
+
delay(100);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
void show(char *p)
|
|
38
|
+
{
|
|
39
|
+
while(*p)
|
|
40
|
+
dat(*p++);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
int main(void)
|
|
44
|
+
{
|
|
45
|
+
unsigned int i;
|
|
46
|
+
|
|
47
|
+
PLL0CON = 0x00;
|
|
48
|
+
PLL0FEED = 0xAA;
|
|
49
|
+
PLL0FEED = 0x55;
|
|
50
|
+
VPBDIV = 0x01;
|
|
51
|
+
|
|
52
|
+
PINSEL0 = 0x00000000;
|
|
53
|
+
PINSEL2 = 0x00000000;
|
|
54
|
+
|
|
55
|
+
IODIR0 = 0x00100C00;
|
|
56
|
+
IODIR1 = 0x00FF0000;
|
|
57
|
+
|
|
58
|
+
IOCLR0 = 0x00100C00;
|
|
59
|
+
IOCLR1 = 0x00FF0000;
|
|
60
|
+
|
|
61
|
+
delay(2000);
|
|
62
|
+
cmd(0x38);
|
|
63
|
+
cmd(0x0C);
|
|
64
|
+
cmd(0x06);
|
|
65
|
+
cmd(0x01);
|
|
66
|
+
delay(20000);
|
|
67
|
+
|
|
68
|
+
CCR = 0x02;
|
|
69
|
+
CCR = 0x00;
|
|
70
|
+
|
|
71
|
+
SEC = 0;
|
|
72
|
+
MIN = 9;
|
|
73
|
+
HOUR = 10;
|
|
74
|
+
DOM = 31;
|
|
75
|
+
MONTH = 10;
|
|
76
|
+
YEAR = 2026;
|
|
77
|
+
DOW = 6;
|
|
78
|
+
|
|
79
|
+
PREINT = 365;
|
|
80
|
+
PREFRAC = 6912;
|
|
81
|
+
|
|
82
|
+
CCR = 0x01;
|
|
83
|
+
|
|
84
|
+
while(1)
|
|
85
|
+
{
|
|
86
|
+
sprintf(str, "Time %02d:%02d:%02d", HOUR, MIN, SEC);
|
|
87
|
+
cmd(0x80);
|
|
88
|
+
show(str);
|
|
89
|
+
|
|
90
|
+
sprintf(str, "%02d/%02d/%04d %s", DOM, MONTH, YEAR, days[DOW]);
|
|
91
|
+
cmd(0xC0);
|
|
92
|
+
show(str);
|
|
93
|
+
|
|
94
|
+
for(i = 0; i < 1000; i++);
|
|
95
|
+
}
|
|
96
|
+
}
|