[Embedded system] experiment key issues and key codes

Disclaimer: This article is a blogger original article. Reproduced please contact bloggers authorization. Bloggers public micro-channel number] [Department of Knowing and Doing the campus. https://blog.csdn.net/cxh_1231/article/details/89716121

Key Question 1:

Question: Suppose 4 th led lights from the lower to the corresponding 4 -bit binary of 0,1,2,3 position, lights is 1 , OFF is 0 ; example 4 ( 0100 ) of the 2 bit corresponds lights, 3 ( 0011 ) of the 0,1 position corresponding to the lights; since 0 is completely destroyed, if 0 is displayed to full brightness ; after you learn to cycle number six, and the assignment to individual register assignment.

Code:

#include "s5pc210.h"
#include "uart.h"

/*****************************************************************************
// Function name	: delay
// Description	    : 延时子程序
// Return type		: void
// Argument         : count,延时的数值
*****************************************************************************/
void delay( int count )
{
	int cnt;

	for( count = count; count>0; count--)
		for( cnt = 0; cnt < 1000; cnt++);
}

int main()
{
	uart_init();

	printf("CVT S5PV210 Jtag GpioLed Test...\n");

	volatile int i,j=0;
	GPH3.GPH3CON = 0x11110000;
	int k=0;
	while(1){

		GPH3.GPH3DAT = 0xFF;//全灭
		for(i = 0; i <= 2000000; i++);

		//显示8::1000
		GPH3.GPH3DAT = ~(0x1<<(0+4));
		for(i = 0; i <= 2000000; i++);

		//显示7::0111
		k=0;
		while(1){
			GPH3.GPH3DAT = ~(0x1<<(1+4));
			delay(1);
			GPH3.GPH3DAT = ~(0x1<<(2+4));
			delay(1);
			GPH3.GPH3DAT = ~(0x1<<(3+4));
			delay(1);
			k++;
			if(k==750)
				break;
		}

		//显示0::0000
		GPH3.GPH3DAT = 0xFF;//全灭
		for(i = 0; i <= 2000000; i++);

		//显示9::1001
		k=0;
		while(1){
			GPH3.GPH3DAT = ~(0x1<<(0+4));
			delay(1);
			GPH3.GPH3DAT = ~(0x1<<(3+4));
			delay(1);
			delay(1);
			k++;
			if(k==750)
				break;
		}

		//显示8::1000
		GPH3.GPH3DAT = ~(0x1<<(0+4));
		for(i = 0; i <= 2000000; i++);


		//显示4::0100
		GPH3.GPH3DAT = ~(0x1<<(1+4));
		for(i = 0; i <= 2000000; i++);

		GPH3.GPH3DAT = 0x0;//全亮
		for(i = 0; i <= 2000000; i++);

		//for(j = 0;j<4;j++){
		//	GPH3.GPH3DAT = ~(0x1<<(j+4));
		//	for(i = 0; i <= 1000000; i++);
		//}
	}
	return 0;
}

Key Question 2:

problem:

  1. After six cycles show your student number (the first X Show after your student number six on a digital x -bit, such as after your student number six is 012345 , the digital display in the leftmost 0 , most the right display 5 and cycles

  1. Advanced: You still display the last six student number ( 012345 )

Code: 

#include "s5pc210.h"
#include "uart.h"


#define U8 unsigned char
unsigned char seg7table[16] = {
    /* 0       1       2       3       4       5       6      7*/

    0xc0,   0xf9,   0xa4,   0xb0,   0x99,   0x92,   0x82,   0xf8,

    /* 8       9      A        B       C       D       E      F*/
    0x80,   0x90,   0x88,   0x83,   0xc6,   0xa1,   0x86,   0x8e,
};

/*****************************************************************************
// Function name	: delay
// Description	    : 延时子程序
// Return type		: void
// Argument         : count,延时的数值
*****************************************************************************/
void delay( int count )
{
	int cnt;

	for( count = count; count>0; count--)
		for( cnt = 0; cnt < 1000; cnt++);
}

int main()
{
	uart_init();

	printf("CVT S5PV210 Jtag Seg Test...\n");

	int i,j=0;

	*((U8*) 0x88007000) = 0x00;

	for( ; ; )	{
		*((U8*) 0x88007000) = ~(0x1<<j++);
		*((U8*) 0x88009000) = seg7table[8];
		delay (1000);
		//delay (1);

		*((U8*) 0x88007000) = ~(0x1<<j++);
		*((U8*) 0x88009000) = seg7table[7];
		delay (1000);
		//delay (1);

		*((U8*) 0x88007000) = ~(0x1<<j++);
		*((U8*) 0x88009000) = seg7table[0];
		delay (1000);
		//delay (1);

		*((U8*) 0x88007000) = ~(0x1<<j++);
		*((U8*) 0x88009000) = seg7table[9];
		delay (1000);
		//delay (1);

		*((U8*) 0x88007000) = ~(0x1<<j++);
		*((U8*) 0x88009000) = seg7table[8];
		delay (1000);
		//delay (1);

		*((U8*) 0x88007000) = ~(0x1<<j++);
		*((U8*) 0x88009000) = seg7table[4];
		delay (1000);
		//delay (1);

		j=0;
		int k=0;
		for(;;){

			*((U8*) 0x88007000) = ~(0x1<<j++);
			*((U8*) 0x88009000) = seg7table[8];
			//delay (1000);
			delay (1);
			*((U8*) 0x88007000) = ~(0x1<<j++);
			*((U8*) 0x88009000) = seg7table[7];
			//delay (1000);
			delay (1);
			*((U8*) 0x88007000) = ~(0x1<<j++);
			*((U8*) 0x88009000) = seg7table[0];
			//delay (1000);
			delay (1);
			*((U8*) 0x88007000) = ~(0x1<<j++);
			*((U8*) 0x88009000) = seg7table[9];
			//delay (1000);
			delay (1);
			*((U8*) 0x88007000) = ~(0x1<<j++);
			*((U8*) 0x88009000) = seg7table[8];
			//delay (1000);
			delay (1);
			*((U8*) 0x88007000) = ~(0x1<<j++);
			*((U8*) 0x88009000) = seg7table[4];
			//delay (1500);
			delay (1);
			k++;
			j=0;
			if(k==500){
				break;
			}
		}
		/* 数码管从0到F依次将字符显示出来 */
	    //for(i=0;i<0x10;i++)		{
			/* 查表并输出数据 */
	    //	*((U8*) 0x88009000) = seg7table[i];
	    //	delay (1000);
   		//}

		/* 数码管从F到0依次将字符显示出来 */
		//for(i=0xf;i>=0x0;i--)		{
	   		/* 查表并输出数据 */
	   	//	*((U8*) 0x88009000) = seg7table[i];
	   	//	delay (1000);

	 	//}
	 }
	return 0;
}

Key Question 3:

problem:

  1. Enter your name in uppercase to lowercase spelling, enter your name spelling variations uppercase lowercase

Code;

 

#include "s5pc210.h"
#include "uart.h"

/*****************************************************************************
// Function name	: delay
// Description	    : 延时子程序
// Return type		: void
// Argument         : count,延时的数值
*****************************************************************************/
void delay( int count )
{
	int cnt;

	for( count = count; count>0; count--)
		for( cnt = 0; cnt < 1000; cnt++);
}

int main()
{
	uart_init(115200);
	Uart_Select(2);

	printf("姓名全拼大小写互换\n");

	int i=0;
	while(1){
		unsigned char ch = 'a';

		if(i==0){
			printf("a→A\n");//
		}
		if(i==10)//这是因为笔者的姓名只有10个字母,输入完成小写10个后,自动提示输入大写,可换。
			printf("\nA→a\n");
		i++;

		ch = Uart_Getch();


		if(0x41<=ch && ch<= 0x5a ){//小写转换成大写
			Uart_SendByte(ch+32);
		}
		else if(0x61<=ch && ch<= 0x7a ){//大写转换成小写
			Uart_SendByte(ch-32);
		}
		//else if(ch == 0x0d)
		//	Uart_SendByte(0x0a);

		//Uart_SendByte(ch+1);
		//if(ch == 0x0d)
		//	Uart_SendByte(0x0a);
	}
}

result:

Guess you like

Origin blog.csdn.net/cxh_1231/article/details/89716121