<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>nRF24LE1 repeat twice the action</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/47744/nrf24le1-repeat-twice-the-action</link><description>Hellow everyone, I&amp;#39;m testing the UART communication between the MCU and the PC. There is communication in both directions, the problem is that even if you only press the keyboard once, the instruction (flashing a led) is repeated twice. Annex code and</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 28 May 2019 01:22:03 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/47744/nrf24le1-repeat-twice-the-action" /><item><title>RE: nRF24LE1 repeat twice the action</title><link>https://devzone.nordicsemi.com/thread/189425?ContentTypeID=1</link><pubDate>Tue, 28 May 2019 01:22:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3d924bc2-2673-4295-806c-f1703b78c064</guid><dc:creator>Artgrutro</dc:creator><description>&lt;p&gt;&lt;span&gt;Kenneth, thank you very much for your prompt response. The program is already running well. I only eliminated the infinite cycle, because I have noticed that whenever an interruption is involved, (happened to me testing deep sleep) the pointer besides going to the direction of the interruption vector, the MCU enters in a general reset or something similar. Incidentally, I had to add a delay of 10 ms at end of every case (1 and 2, lines 88 y 93), as seen in the corrected program that I append, because if there are some rare careacteres in the terminal, when executing the printf function, I realized this because option 3 of the switch case a blinking that delays works as a delay and in that option the characters were shown well, if someone could explain why, I would appreciate it. I&amp;#39;m going to take a look at nRF52832. Thanks again.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;stdint.h&amp;gt;
#include &amp;quot;nrf24le1.h&amp;quot;
#include &amp;quot;hal_uart.h&amp;quot;
#include &amp;quot;hal_clk.h&amp;quot;
#include &amp;quot;hal_delay.h&amp;quot;

#define	SW	 P01
#define	LED	 P00


// Cusomization of low level stdio function. Used by for example printf().
#ifdef __ICC8051__
int putchar(int c)
#else /*presume C51 or other accepting compilator*/
char putchar(char c)
#endif
{
  hal_uart_putchar(c);
  return c;
}

// Cusomization of low level stdio function. Used by for example gets().
#ifdef __ICC8051__
int getchar(void)
#else /*presume C51 or other accepting compilator*/
char getchar(void)
#endif
{
  return hal_uart_getchar();
}

//Variables Globales...................

//Prototipo de funciones...............
void Boton(void);
void Parpadeo_LED(void);
void Parpadeo_Rapido_LED(void);

// Repeated putchar to print a string
void putstring(char *s)
{
  while(*s != 0)
		putchar(*s++);	//Es igual a la anterior
}


//MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN 
void main(void)
{
  //Variables locales.....................
	char caracter;
	char edoLED;
	/*
	*Configure TXD pin as output.
  *P0.5, P0.3 and P1.0 are configured as outputs to make the example run on
  *either 24-pin, 32-pin or 48-pin nRF24LE1 variants.
  */
	
	P0DIR = 0xD6;		//1101 0110 
  P1DIR = 0xFE;

	P0CON = 0x31;	//0011 0000 + 1 Digital Input, buffer ON, Pull Down resistor connected  

	// Initializes the UART
  hal_uart_init(UART_BAUD_9K6);

  // Wait for XOSC to start to ensure proper UART baudrate
  while(hal_clk_get_16m_source() != HAL_CLK_XOSC16M)
  {}

  // Enable global interrupts
  EA = 1;
			
	//Desplegar MENU:		
	putstring(&amp;quot;\r\nMENU DE INICIO\r\n&amp;quot;);
	putstring(&amp;quot;\r\n1. Encender LED\r\n&amp;quot;);
	putstring(&amp;quot;\r2. Apagar LED\r\n&amp;quot;);
	
	//Obtener respuesta y ejecutarla
	caracter = hal_uart_getchar();   // original: getchar();	
	printf(&amp;quot;\r\nTu seleccion fue: %c \r\n\n\n&amp;quot;, caracter); 
	
		switch (caracter)
		{
			case &amp;#39;1&amp;#39;:	
				LED = 1;
				delay_ms(10);	//Si se quita este retraso manda caracteres raros 
			break;
			
			case &amp;#39;2&amp;#39;:	
				LED = 0;
				delay_ms(10);
			break;
			
			default:
			edoLED = LED;
			printf(&amp;quot;\r\nSELECION NO VALIDA\r\n&amp;quot;);
			Parpadeo_LED();
			LED = edoLED;
			break;	
		}
}//Fin MAIN Fin MAIN Fin MAIN Fin MAIN Fin MAIN Fin MAIN Fin MAIN Fin MAIN Fin MAIN Fin 



//BOTON BOTON BOTON BOTON BOTON BOTON BOTON BOTON BOTON BOTON BOTON BOTON BOTON BOTON  
void Boton(void)
{
	while (SW == 1){}
	delay_ms(15);
	while (SW == 0){}
	delay_ms(15);	
}// Fin BOTON Fin BOTON Fin BOTON Fin BOTON Fin BOTON Fin BOTON Fin BOTON Fin BOTON Fin 




// PARPADEO_LED PARPADEO_LED PARPADEO_LED PARPADEO_LED PARPADEO_LED PARPADEO_LED  
void Parpadeo_LED(void)
{
  //Variables locales
  char i;
  for(i=0; i&amp;lt;3; i++)                           
        {
        LED=1;
        delay_ms(400);
        LED=0;
        delay_ms(400);
        }
}// Fin PARPADEO_LED Fin PARPADEO_LED Fin PARPADEO_LED Fin PARPADEO_LED Fin PARPADEO_LED 




//PARPADEO_RAPIDO_LED PARPADEO_RAPIDO_LED PARPADEO_RAPIDO_LED PARPADEO_RAPIDO_LED  
void Parpadeo_Rapido_LED(void)
{
  //Variables locales
  char i;
  for(i=0; i&amp;lt;5; i++)                           
        {
        LED=1;
					delay_ms(60);	//Original: delay_us(100);
        LED=0;
        delay_ms(60);
        }
}//Fin PARPADEO_RAPIDO_LED Fin PARPADEO_RAPIDO_LED Fin PARPADEO_RAPIDO_LED Fin  
/** @} */&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/Terminal2.jpg" /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF24LE1 repeat twice the action</title><link>https://devzone.nordicsemi.com/thread/189296?ContentTypeID=1</link><pubDate>Mon, 27 May 2019 11:44:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:00d5db3f-aa4d-4cc6-9cd5-a21b4c3f9204</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Have you scoped the UART interface, to check what data is incoming on&amp;nbsp;hal_uart_getchar()?&lt;/p&gt;
&lt;p&gt;Maybe you need some kind of debounce to ensure that bounce on the input doesn&amp;#39;t trigger the same code several times.&lt;/p&gt;
&lt;p&gt;For new development I strongly recommend to check out the nRF52832. There have not been done any new maintenance for the nRF24-series for several years.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>