Exemplo n.º 1
0
void main()
{
	char key[17],i;
	for(i=0;i<16;i++)
	{
		key[i]='*';
	}
	key[17]=0;

	while(1)
	{
		
		//lcd(key);
		//lcd("#n%d  ",_sdat_in);
		lcd("#n%d  ",_key);
		if(sw1()==0)
		{
			beep_b(4);
			sleep(100);
			for(i=0;i<16;i++)
			{
				key[i]= uart_getkey();
			}
			key[17]=0;
			lcd(key);
		}
	}
}
Exemplo n.º 2
0
void main()
{
	char command; 
	uart_set_baud(1200);
	while(1)
	{
		command = uart_getkey();
		lcd("Key Value: %c  ",command);
	}
}
Exemplo n.º 3
0
void interrupt 20 SCI0_ISR(void)
{     
  SCI0CR2_RIE=0;
  //此处为串口中断需要处理的事情
  uart_putchar(u8_RCV_Ch=uart_getkey());
  //PORTA_PA0=~PORTA_PA0;
  PORTB_PB7=~PORTB_PB7; 
  switch(u8_RCV_Ch)
    { 
      case 'u':
        u8_RCV_Ch=0xff;
        PWME_PWME1 = 1;           //开启PWM0波形输出   
        if(PWMPER1>15)            //增大频率
            PWMPER1-=5; 
      break; 
      case 'd':
        u8_RCV_Ch=0xff; 
        PWME_PWME1 = 1;
        if(PWMPER1<255)           //减小频率
            PWMPER1++;
        if(PWMDTY1>PWMPER1+10)    //减小占空比
              PWMDTY1=PWMPER1*4/5;  //20%
      break; 
      case 'l':
        u8_RCV_Ch=0xff;
        PWME_PWME1 = 1;
        if(PWMDTY1<PWMPER1)       //增大占空比
            PWMDTY1++;
      break; 
      case 'r':
        u8_RCV_Ch=0xff; 
        PWME_PWME1 = 1;
        if(PWMDTY1<PWMPER1)       //减小占空比
              PWMDTY1--;
      break;      
      default:             
      break;      
    }//switch(u8_RCV_Ch)      
    
  //Beep();
  SCI0CR2_RIE = 1;    
}