This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

NRF9E5 code problem

Hi I'm looking to Program the NRF9E5 RX board so that the LED remains high until the switch is pressed on TX. So the TX button would turn the LED high and remain so until the TX Switch is pressed. I would like to do this for two LEDs. But for the code below I am trying one (P0.2) just to check.

The code below (RX) is done on Keil uvision 4.72.9:

void Receiver(void) { unsigned char b; unsigned char b1,b2; unsigned char oldb1,oldb2;

TXEN = 0;
for(;;)
{
    b = ReceivePacket();
			b1= b&0;//0010
			//b2=b&2;//0100
			oldb1=P0.2;
			//oldb2=P.2;
    
			for(;;){
			p0.2=~p0.2;
			delay_ms(500);
   }
		if(p0.2==0) 
			p0.2 = 1;  
		else p0.2 = 0; 
		}
		end if;
		}
	

void Init(void)

Any assistance would be appreciated greatly.

  • Hi John

    Please use the code tag to include code, otherwise the formatting will be messy ;)

    It seems you are blinking P0.2 in an infinite loop, which doesn't really make sense if you are waiting for button input. What pin are you using for the button?

    Best regards Torbjørn

  • Hi Torbjørn,

    Thanks for your Reply.

    I have the transmitter just set at P0_DIR=0XFF;

    Would I have to set the coressponding switch for the LED on the tx side?

    Have changed the code to remove the loop.

    I think that it is checking the recieve packet for a 1 to turn on P0.2?

    Basically like a wireless light switch is what I'm looking

    I have attached the code below and have the updated code here. void Receiver(void) void Delay500us(volatile unsigned char n)

    {
        unsigned char b;
    		unsigned char b1,b2;
    		unsigned char oldb1,oldb2;
    		
    	
        TXEN = 0;
        for(;;)
        {
            b = ReceivePacket();
    				b1= b&0;//0010
    				//b2=b&2;//0100
    				oldb1=P0.2;
    				//oldb2=P.2;
            
    				p0.2=~p0.2;
    				delay_ms(500);
           }
    				if(p0.2==0) 
    				p0.2 = 1;  
    				else p0.2 = 0; 
    			}
    			end if;
    			}
    		
    
    
    void Init(void)
    

    Any help would be greatly appreciated

  • Hi Torbjørn,

    Thanks for your Reply.

    I have the transmitter just set at P0_DIR=0XFF;

    Would I have to set the coressponding switch for the LED on the tx side?

    Have changed the code to remove the loop.

    I think that it is checking the recieve packet for a 1 to turn on P0.2?

    Basically like a wireless light switch is what I'm looking

    I have attached the code below and have the updated code here. void Receiver(void) void Delay500us(volatile unsigned char n)

    { unsigned char b; unsigned char b1,b2; unsigned char oldb1,oldb2;

    TXEN = 0;
    for(;;)
    {
        b = ReceivePacket();
    			b1= b&0;//0010
    			//b2=b&2;//0100
    			oldb1=P0.2;
    			//oldb2=P.2;
        
    			p0.2=~p0.2;
    			delay_ms(500);
       }
    			if(p0.2==0) 
    			p0.2 = 1;  
    			else p0.2 = 0; 
    		}
    		end if;
    		}
    	
    

    void Init(void)

Related