Ejemplo n.º 1
0
Archivo: main.c Proyecto: lab11/ving
void initLeds(void) {
	MATRIX->CCFG_SYSIO |= CCFG_SYSIO_SYSIO12;
	MATRIX->CCFG_SYSIO |= CCFG_SYSIO_SYSIO11;
	MATRIX->CCFG_SYSIO |= CCFG_SYSIO_SYSIO10;
	
	pmc_enable_periph_clk(ID_PIOB);
	pmc_enable_periph_clk(ID_PIOA);
	pio_set_output(PIOB, PIO_PB10, LOW, DISABLE, ENABLE);
	pio_set_output(PIOB, PIO_PB11, LOW, DISABLE, ENABLE);
	pio_set_output(PIOB, PIO_PB12, LOW, DISABLE, ENABLE);
}
Ejemplo n.º 2
0
int main(void)
{
	printk("Starting timer tests\n");

	pio_set_output(GPIOA_BASE, 3, 0);
	pio_set_output(GPIOC_BASE, 7, 0);

	add_thread(&thread_a, DEFAULT_PRIORITY);

	return 0;

}
Ejemplo n.º 3
0
int main(void)
{
	
	int speed = 8192;
	//Def leds
	pio_set_output(PORT_LED_GREEN,MASK_LED_GREEN,1,0,0);
	pmc_enable_periph_clk(ID_LED_GREEN);
	pio_clear(PORT_LED_GREEN, MASK_LED_GREEN);
	/* Initialize the SAM system */
	sysclk_init();
	
	/* Disable the watchdog */
	WDT->WDT_MR = WDT_MR_WDDIS;

	/** Configura o timer */
	configure_tc();
	
	/* Configura os botões */
	configure_buttons();

	while (1) {
		
		/* Entra em modo sleep */
		pmc_sleep(SAM_PM_SMODE_SLEEP_WFI);
		
	}
}
Ejemplo n.º 4
0
int main(void)
{
	/* Initialize the SAM system */
	sysclk_init();
	/* Disable the watchdog */
	WDT->WDT_MR = WDT_MR_WDDIS;

	/** Configura o timer */
	configure_tc();
	
	/* Configura os botões */
	configure_buttons();
	
	pio_set_output(PORT_LED_BLUE  , MASK_LED_BLUE	,1,0,0);

	pio_clear(PIOA, (1 << PIN_LED_BLUE));

	while (1) {
		
		
		/* Entra em modo sleep */
		pmc_sleep(SAM_PM_SMODE_SLEEP_WFI);

		
	}
}
/**
 * \brief Perform complete pin(s) configuration; general attributes and PIO init
 * if necessary.
 *
 * \param p_pio Pointer to a PIO instance.
 * \param ul_type PIO type.
 * \param ul_mask Bitmask of one or more pin(s) to configure.
 * \param ul_attribute Pins attributes.
 *
 * \return Whether the pin(s) have been configured properly.
 */
uint32_t pio_configure(Pio *p_pio, const pio_type_t ul_type,
		const uint32_t ul_mask, const uint32_t ul_attribute)
{
	/* Configure pins */
	switch (ul_type) {
	case PIO_PERIPH_A:
	case PIO_PERIPH_B:
#     if (SAM3S || SAM3N || SAM4S)
	case PIO_PERIPH_C:
	case PIO_PERIPH_D:
#     endif
		pio_set_peripheral(p_pio, ul_type, ul_mask);
		pio_pull_up(p_pio, ul_mask, (ul_attribute & PIO_PULLUP));
		break;

	case PIO_INPUT:
		pio_set_input(p_pio, ul_mask, ul_attribute);
		break;

	case PIO_OUTPUT_0:
	case PIO_OUTPUT_1:
		pio_set_output(p_pio, ul_mask, (ul_type == PIO_OUTPUT_1),
				(ul_attribute & PIO_OPENDRAIN) ? 1 : 0,
				(ul_attribute & PIO_PULLUP) ? 1 : 0);
		break;

	default:
		return 0;
	}

	return 1;
}
Ejemplo n.º 6
0
/**
 * \brief Perform a HW initialization to the PHY and set up clocks.
 *
 * This should be called only once to initialize the PHY pre-settings.
 * The PHY address is the reset status of CRS, RXD[3:0] (the emacPins' pullups).
 * The COL pin is used to select MII mode on reset (pulled up for Reduced MII).
 * The RXDV pin is used to select test mode on reset (pulled up for test mode).
 * The above pins should be predefined for corresponding settings in resetPins.
 * The GMAC peripheral pins are configured after the reset is done.
 *
 * \param p_gmac   Pointer to the GMAC instance.
 * \param uc_phy_addr PHY address.
 * \param ul_mck GMAC MCK.
 *
 * Return GMAC_OK if successfully, GMAC_TIMEOUT if timeout.
 */
uint8_t ethernet_phy_init(Gmac *p_gmac, uint8_t uc_phy_addr, uint32_t mck)
{
	uint8_t uc_rc;
	uint8_t uc_phy;

#if 0	// chrishamm
	pio_set_output(PIN_GMAC_RESET_PIO, PIN_GMAC_RESET_MASK, 1,  false, true);
	pio_set_input(PIN_GMAC_INT_PIO, PIN_GMAC_INT_MASK, PIO_PULLUP);
	pio_set_peripheral(PIN_GMAC_PIO, PIN_GMAC_PERIPH, PIN_GMAC_MASK);
#endif

	ethernet_phy_reset(GMAC,uc_phy_addr);

	/* Configure GMAC runtime clock */
	uc_rc = gmac_set_mdc_clock(p_gmac, mck);
	if (uc_rc != GMAC_OK) {
		return 0;
	}

	/* Check PHY Address */
	uc_phy = ethernet_phy_find_valid(p_gmac, uc_phy_addr, 0);
	if (uc_phy == 0xFF) {
		return 0;
	}
	if (uc_phy != uc_phy_addr) {
		ethernet_phy_reset(p_gmac, uc_phy_addr);
	}

	return uc_rc;
}
Ejemplo n.º 7
0
void config_led(void){
	/* Configure LED 1 */
	pmc_enable_periph_clk(ID_LED_BLUE);
	pio_set_output(PORT_LED_BLUE  , MASK_LED_BLUE	,1,0,0);
	functionPIO(ID_PIOA, PIN_LED_GREEN, PIOA);
	functionPIO(ID_PIOC, PIN_LED_RED, PIOC);
}
Ejemplo n.º 8
0
int main(void)
{
	// Disable watchdog timer
	wdt_disable(WDT);

	// Enable peripheral clock to be able to read button state
	pmc_enable_periph_clk(BUTTONS_PIO_ID);
	while (!pmc_is_periph_clk_enabled(BUTTONS_PIO_ID));

	// Configure pins
	pio_set_output(LEDS_PIO, ALL_LEDS, 1, false, false);
	pio_set_input(BUTTONS_PIO, ALL_BUTTONS, PIO_PULLUP);

	while (true)
	{
		pio_set(LEDS_PIO, LED_ORANGE);
		pio_clear(LEDS_PIO, LED_GREEN);
		while (pio_get(BUTTONS_PIO, PIO_INPUT, BUTTON1));
		pio_clear(LEDS_PIO, LED_ORANGE);
		pio_set(LEDS_PIO, LED_GREEN);
		while (pio_get(BUTTONS_PIO, PIO_INPUT, BUTTON2));
	}

	return 0;
}
Ejemplo n.º 9
0
/**
 * \brief Initialize SAM4E_XPRO board for low power test.
 */
void init_specific_board(void)
{
	/* Disable all Extra functions in matrix except for SWD CLK/IO */
	matrix_set_system_io(0x00001C30);

	/* Configure all PIOs as inputs to save power */
	pio_set_input(PIOA, 0xFFFFFFFF, PIO_PULLUP);
	pio_set_input(PIOB, 0xFFFFFFFF, PIO_PULLUP);
	pio_set_input(PIOC, 0xFFFFFFFF, PIO_PULLUP);
	pio_set_input(PIOD, 0xFFFFFFFF, PIO_PULLUP);
	pio_set_input(PIOE, 0xFFFFFFFF, PIO_PULLUP);

	/* Disable USB Clock */
	pmc_disable_udpck();

	/* Disable pull-up on PHY */
	pio_pull_up(PIOD, PIO_PD0 | PIO_PD4 | PIO_PD5 | PIO_PD6 | PIO_PD7, 0);
	/* Hold PHY in reset to avoid the clock output switching */
	pio_set_output(PIOD, PIO_PD31, 0, 0, 0);

	/* Disable pull-up on VBUS */
	pio_pull_up(PIOE, PIO_PE2, 0);
	/* Disable PIO pull-up for PB10(USB_DDM), PB11(USB_DDP) */
	pio_pull_up(PIOB, PIO_PB10 | PIO_PB11, 0);

	/* Enable the PMC clocks of push button for wakeup */
	pmc_enable_periph_clk(ID_PIOE);
	pio_handler_set_priority(PIOE, PIOE_IRQn, IRQ_PRIOR_PIO);
}
Ejemplo n.º 10
0
/**
 *  \brief Configure the LEDs
 *
 */
static void configure_leds(void)
{
	pmc_enable_periph_clk(ID_LED_BLUE);
				
	/**
	*	Configura saída
	*/
	pio_set_output(PORT_LED_BLUE  , MASK_LED_BLUE	,1,0,0);

}
Ejemplo n.º 11
0
void platform_early_init(void)
{
	SystemInit();

	sam_timer_early_init();

	wdt_disable(WDT);

	pmc_enable_periph_clk(ID_PIOC);
	pio_set_output(PIOC, PIO_PC9, 0, 0, 1);

	sam_debug_early_init();
}
Ejemplo n.º 12
0
Archivo: adc.c Proyecto: vis81/uspi
void adc_init()
{
	pio_init();
	spi_init();
	//nSYNC/nPD
	pio_set_output(ADC_nSYNC,0,FALSE,FALSE);
			
	//ADC_nDRDY
	pio_set_input(ADC_nDRDY0,FALSE,FALSE);
	pio_set_input(ADC_nDRDY1,FALSE,FALSE);
	pio_set_input(ADC_nDRDY2,FALSE,FALSE);
	gAdcDesc.state=ADC_IDLE;
#if PWM_DEBUG
	pwm_init();
#endif
}
Ejemplo n.º 13
0
/**
 *  Interrupt handler for TC0 interrupt. 
 */
void TC0_Handler(void)
{
	volatile uint32_t ul_dummy;

	/* Clear status bit to acknowledge interrupt */
	ul_dummy = tc_get_status(TC0,0);

	/* Avoid compiler warning */
	UNUSED(ul_dummy);

	/** Muda o estado do LED */
	if(!pio_get_output_data_status(PORT_LED_GREEN,MASK_LED_GREEN)){
		pio_set_output(PORT_LED_GREEN,MASK_LED_GREEN,1,0,0);
	}else{
		pio_clear(PORT_LED_GREEN,MASK_LED_GREEN);
	}


}
Ejemplo n.º 14
0
/**
 * \brief Configures SAMG55 for low power demo.
 */
void init_specific_board(void)
{
	/* For the lowest power consumption all pins should have defined state
	 * e.g. no floating pins.
	 * Set all pins as input with pull-up enabled with the exception:
	 * - CDC UART RX (PA27) should not be pulled up because this pin is
	 *   driven by the EDBG in this application
	 * - CDC UART TX (PA28) This is actively driven by the SAMG55 in this
	 *   application
	 * - PB04 should set as output
	 * - PB8 PB9 PB10 PB11 should set as output
	 */
	pio_set_input(PIOA, 0xE7FFFFFF, PIO_PULLUP);
	pio_set_input(PIOA, 0x18000000, PIO_DEFAULT);
	pio_set_input(PIOB, 0xFFFF0EF, PIO_PULLUP);
	pio_set_output(PIOB, 0xF10, HIGH, DISABLE, DISABLE);
	/* Enable the PMC clocks of push button for wakeup */
	pmc_enable_periph_clk(ID_PIOA);
	pio_handler_set_priority(PIOA, PIOA_IRQn, IRQ_PRIORITY_PIO);
}
Ejemplo n.º 15
0
 */
static void configure_leds(void) {
	pmc_enable_periph_clk(PIN_LED_BLUE_ID);	
	pio_set_output(PIN_LED_BLUE_PIO, PIN_LED_BLUE_MASK, 1, 0, 0);
Ejemplo n.º 16
0
/**
 *  \brief Configure the LEDs
 *
 */
static void configure_leds(void)
{
	pmc_enable_periph_clk(ID_LED_GREEN);
	pio_set_output(PORT_LED_GREEN , MASK_LED_GREEN  ,1,0,0);
}
Ejemplo n.º 17
0
/**
 * \brief Application entry point for PWM PDC example.
 *
 * \return Unused (ANSI-C compatibility).
 */
int main(void)
{

	/* Initialize the SAM system */
	sysclk_init();
	board_init();

	/* Configure the console uart for debug infomation */
	configure_console();

	/* Output example information */
	puts(STRING_HEADER);

/* Enable PWM peripheral clock */
	pmc_enable_periph_clk(ID_PWM);
	
	/*A Disable PWM channels
	- Register: PWM_DIS (PWM Disable)
	- Kanal 0: Motor1_X
	- Kanal 1: Motor1_Y	
	- Kanal 2: Motor1_Z
	- Kanal 3: Referenzsignals 
	*/
	pwm_channel_disable(PWM, PWM_CHANNEL_0);
	pwm_channel_disable(PWM, PWM_CHANNEL_1);
	pwm_channel_disable(PWM, PWM_CHANNEL_2);
	pwm_channel_disable(PWM, PWM_CHANNEL_3);
	
	/*A PWM-Leitungen (C.2 - C.9) im Prozessor vom
	PIO-Controller trennen und auf peripheral Funktion B setzen */

	for (int pinId = 2; pinId <= 9; pinId++) { 
		pio_set_peripheral(PIOC, PIO_TYPE_PIO_PERIPH_B, (1u << pinId));
	}
	
	/*A Clock einstellen
	- Set PWM clock A for all channels, clock B not used
	 */
	pwm_clock_t clock_setting = {
			.ul_clka = PWM_FREQUENCY * PERIOD_VALUE,
			.ul_clkb = 0,
			.ul_mck = sysclk_get_cpu_hz() // diese Funktion gibt 84 Mhz zurück!
		};
	pwm_init(PWM, &clock_setting);
	
	/*A Kanäle 0,1,2 als synchron festlegen
	*/
	// zunächst die generellen Eigenschaften der synchronen Channels initialisieren 
	pwm_channel_t sync_channel = {
		/* die Motor Kanäle sollen alle Center aligned sein */
		.alignment = PWM_ALIGN_CENTER,
		/* die Motor Kanäle sollen mit Low Polarität starten */
		.polarity = PWM_LOW,
		/* Alle Motor Kanäle sollen Clock A verwenden, da sie mit doppelter Basisfrequenz getaktet werden müssen wegen Center aligned */
		.ul_prescaler = PWM_CMR_CPRE_CLKA,
		/* Periode einstellen */
		.ul_period = PERIOD_VALUE,
		/* Duty cycle initial setzen */
		.ul_duty = INIT_DUTY_VALUE,
		/* der channel soll synchron sein */
		.b_sync_ch = true,
		 
		 .b_deadtime_generator = true,
		 
		 .us_deadtime_pwmh = 1,
		 
		 .us_deadtime_pwml = 1 
	};

	/* als erstes dann den Channel 0 initialisieren, indem nur das Channel Attribut in der Struktur von oben neu gesetzt wird,
	der REst bleibt gleich...
	*/
	sync_channel.channel = PWM_CHANNEL_0;
	pwm_channel_init(PWM, &sync_channel);
	// das gleiche dann mit den beiden anderen zu synchronisierenden Channels
	sync_channel.channel = PWM_CHANNEL_1;
	pwm_channel_init(PWM, &sync_channel);
	sync_channel.channel = PWM_CHANNEL_2;
	pwm_channel_init(PWM, &sync_channel);

	/*
	 * Initialize PWM synchronous channels
	 * Synchronous Update Mode: Automatic update duty cycle value by the PDC
	 * and automatic update of synchronous channels. The update occurs when
	 * the Update Period elapses (MODE 2 --> Vorsicht vor Verwirrung: dies entspricht der "Methode 3" aus dem Datasheet!).
	 * Synchronous Update Period = MAX_SYNC_UPDATE_PERIOD.
	 */
	pwm_sync_init(PWM, PWM_SYNC_UPDATE_MODE_2, MAX_SYNC_UPDATE_PERIOD);

	/*
	 * Request PDC transfer as soon as the synchronous update period elapses
	 */
	pwm_pdc_set_request_mode(PWM, PWM_PDC_UPDATE_PERIOD_ELAPSED, (1 << 0));
	
	/* Aktiviere alle synchronen channel durch aktivieren von channel 0, channel 1 und 2 werden automatisch synchron mit gestartet 
	zusätzlich noch den Refernzchannel "synchron" mitstarten
	die ASF funktion channel_enable erlaubt leider nur die Übergabe eines Kanals, also müssen wir hier wohl mit direktem Zugriff auf das Register arbeiten */
	pwm_channel_enable(PWM, PWM_CHANNEL_0);
  // ref channel funktioniert noch nicht, muss noch debugged werden  pwm_channel_enable(PWM, PWM_CHANNEL_3);
  
  pmc_enable_periph_clk(ID_PIOA);
  pio_set_output(PIOA, PIO_PA23, LOW, DISABLE, ENABLE);
  
  int angle = 0;
  int up = 1;
  float sinus = 0;
  float a;
  
	while (1) {
		
		pio_set(PIOA, PIO_PA23);
		for (int i = 0; i < 1000; i++)
		{
			sinus = sin(0.343543);
			a = sinus;
		}
		
		pio_clear(PIOA, PIO_PA23);
		delay_us(4);
		
		
		/*display_menu();
		uint32_t angle = get_num_value();
		struct SV pwm = get_vector_for_angle(angle);
		SVPWM(pwm.u, pwm.v, pwm.w);
		printf("The angle is %i degrees.", angle);
		
		for (int i = 0; i <= 360; i++) {
			struct SV pwm = get_vector_for_angle(i);
			SVPWM(pwm.u, pwm.v, pwm.w);
			printf("%i Grad\r\n", i);
			delay_ms(40);
			
		}
		for (int i = 360; i >= 0; i--) {
			struct SV pwm = get_vector_for_angle(i);
			SVPWM(pwm.u, pwm.v, pwm.w);
			printf("%i Grad\r\n", i);
			delay_ms(40);
			
		}*/
	}
}
Ejemplo n.º 18
0
int main (void)
{

	/**
	* Inicializando o clock do uP
	*/
	sysclk_init();
	
	/** 
	*  Desabilitando o WathDog do uP
	*/
	WDT->WDT_MR = WDT_MR_WDDIS;
		
	/**
	* Ativa clock nos periféricos
	*/
	_pmc_enable_clock_periferico(ID_LED_BLUE);
	_pmc_enable_clock_periferico(ID_LED_GREEN);		// Redundante mas não tem problema !
	_pmc_enable_clock_periferico(ID_LED_RED);
	_pmc_enable_clock_periferico(ID_BUT_2);
				
	/**
	*	Configura saída
	*/
	pio_set_output(PORT_LED_BLUE  , MASK_LED_BLUE	,1,0,0);
	pio_set_output(PORT_LED_GREEN , MASK_LED_GREEN  ,1,0,0);
	pio_set_output(PORT_LED_RED	  , MASK_LED_RED	,1,0,0);
	


	
	/**
	* Configura entrada
	*/ 
	pio_set_input(PORT_BUT_2, MASK_BUT_2, PIO_PULLUP | PIO_DEBOUNCE);
	
	/*
	 * Configura divisor do clock para debounce
	 */
	pio_set_debounce_filter(PORT_BUT_2, MASK_BUT_2, 100);
	

	
	/* 
	*	Configura interrupção para acontecer em borda de descida.
	*/
	pio_handler_set(PIOB, ID_BUT_2, MASK_BUT_2, PIO_IT_FALL_EDGE, push_button_handle);
				
	/*
	*	Ativa interrupção no periférico B porta do botão
	*/	
	pio_enable_interrupt(PORT_BUT_2, MASK_BUT_2);	
	/*
	*	Configura a prioridade da interrupção no pORTB
	*/
	NVIC_SetPriority((IRQn_Type)PIOB_IRQn, 0);
	
	/*
	*	Ativa interrupção no port B
	*/
	NVIC_EnableIRQ((IRQn_Type)PIOB_IRQn);
	
	/**
	*	Loop infinito
	*/
	while(1){
	    /*
		pio_set(PIOA, (1 << PIN_LED_BLUE));
		delay_ms(500);
		pio_clear(PIOA, (1 << PIN_LED_BLUE));
		delay_ms(500);
		*/
	}
}
Ejemplo n.º 19
0
int main(void)
{
	uint8_t uc_key;

	/* Initialize the system */
	sysclk_init();
	board_init();

	/* Configure LED 1 */
	pmc_enable_periph_clk(PIN_LED_BLUE_ID);
	pio_set_output(PIN_LED_BLUE_PIO , PIN_LED_BLUE_MASK, 1, 0, 0);

	/* Initialize debug console */
	config_uart();
	
	/* frase de boas vindas */
	puts(" ---------------------------- \n\r"
	 	 " Bem vindo terraquio !		\n\r"
		 " ---------------------------- \n\r");
	
	/* Enable peripheral clock */
	pmc_enable_periph_clk(ID_SMC);

	/** Configura o LEDs */
	configure_leds();

	/** Configura o timer */
	configure_tc();


	/* Configuração LCD */
	configure_lcd();
	
	desenhaCabecalho();
	
	/* display main menu */
	display_menu();

	while (1) {
		
		
		usart_serial_getchar((Usart *)CONSOLE_UART, &uc_key);	
		switch (uc_key) {
			case '1':
				display_menu();
				break;
			case '2':
				flagLED = 0;
				pio_clear(PIN_LED_BLUE_PIO, PIN_LED_BLUE_MASK);
				puts("Led ON \n\r");
				break;
			case '3' :
				flagLED = 1;
				pio_set(PIN_LED_BLUE_PIO, PIN_LED_BLUE_MASK);
				puts("Led OFF \n\r");
				break;
			case '4' :
				flagLED = 2;
				pio_set(PIN_LED_BLUE_PIO, PIN_LED_BLUE_MASK);
				puts("Led OFF \n\r");
				break;
			case '5' :
				flagLED = 3;
				pio_set(PIN_LED_BLUE_PIO, PIN_LED_BLUE_MASK);
				puts("Defina a o valor da Frequência (0-65356) \n\r");
				usart_serial_getchar((Usart *)CONSOLE_UART, &uc_key);
				//tc_write_rc(uc_key);
				break;
				
			default:
				printf("Opcao nao definida: %d \n\r", uc_key);
		}	
	}
}
Ejemplo n.º 20
0
int main(void)
{
	uint8_t uc_key;

	/* Initialize the system */
	sysclk_init();
	board_init();

	/* Configure LED 1 */
	pmc_enable_periph_clk(ID_LED_BLUE);
	pio_set_output(PORT_LED_BLUE  , MASK_LED_BLUE	,1,0,0);

	/* Initialize debug console */
	config_uart();
	
	/* frase de boas vindas */
	puts(" ---------------------------- \n\r"
	 	 " Bem vindo Corsi  !		\n\r"
		 " ---------------------------- \n\r");
		 
	/* display main menu */
	display_menu();
	configure_tc();
	TC0_Handler();
	
	pio_clear(PORT_LED_RED, MASK_LED_RED);
	pio_set(PORT_LED_GREEN, MASK_LED_GREEN);
	
	PIOA->PIO_PER = (1 << PIN_LED_BLUE );
	PIOA->PIO_OER |=  (1 << PIN_LED_BLUE );
	
	
	PMC->PMC_PCER0 |= ID_PIOC;
	PIOC->PIO_PER |= (1 << PIN_LED_RED );
	PIOC->PIO_OER |=  (1 << PIN_LED_RED );
	
	
	tc_stop(TC0, 0);
	PIOA->PIO_SODR = (1 << PIN_LED_BLUE );
	PIOC->PIO_CODR = (1 << PIN_LED_RED );
	
	while (1) {
		usart_serial_getchar((Usart *)CONSOLE_UART, &uc_key);	
		switch (uc_key) {
			case '1':
				display_menu();
				break;
			case '2':
				tc_start(TC0,0);
				PIOA->PIO_CODR = (1 << PIN_LED_BLUE );
				
				puts("Led BLUE ON \n\r");
				break;
			case '3' :
				tc_stop(TC0, 0);
				PIOA->PIO_SODR = (1 << PIN_LED_BLUE );
				puts("Led BLUE OFF \n\r");
			
				break;
			case '4':
				tc_start(TC0,0);
				pio_clear(PORT_LED_GREEN, MASK_LED_GREEN);
				puts("Led GREEN ON \n\r");
				break;
			case '5' :
				tc_stop(TC0, 0);

				pio_set(PORT_LED_GREEN, MASK_LED_GREEN);
				puts("Led GREEN OFF \n\r");
				break;
			case '6':
					tc_start(TC0,0);
					PIOC->PIO_SODR = (1 << PIN_LED_RED );
				
				puts("Led RED ON \n\r");
			break;
			case '7' :
				tc_stop(TC0, 0);
				PIOC->PIO_CODR = (1 << PIN_LED_RED );
				puts("Led RED OFF \n\r");
			break;
			case '8' :
				
				tc_write_rc(TC0, 0, tc_read_rc(TC0,0) * 0.5);
				puts("aumentando \n\r");
				break;
			case '9' :
				
				tc_write_rc(TC0, 0, tc_read_rc(TC0,0) * 1.4);
				puts("diminuindo \n\r");
				break;				
			default:
				printf("Opcao nao definida: %d \n\r", uc_key);
		}	
	}
}