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

Unable to configure Port 1 as input.

Dear Team,

Greetings,

I am facing a problem for configuring Port 1 as input. I have connected a push button on P1.4 and an led on P0.0. I want to perform a simple task, i.e. when I press button then LED must turn on, else LED must be off. I have used NRF24LE1, 32 pin package.

#include "reg24le1.h"

void main()
{
	P0DIR = 0x00;  // set PORT0 as output
	P1DIR = 0xff;  // set PORT1 as input
	while(1)  // infinite loop
	{
		if (P1 == 0x10)     // check P1.4 is high
		{
			P0 = 0x01;
		}
		else
		{
			P0 = 0x00;
		}
	}
}

Parents Reply
  • I am writing the program using keil IDE. I have installed nrfprobe software in my pc, but I am not using it. I am generating .hex file and loading it to nrf24le1 chip using mpro programmer. I have also installed nrfsdk.

    Other examples such as enhanced_shockburst_ptx_nrf24le1 and enhanced_shockburst_prx_nrf24le1, gazell pair are working. 

    But, while I was trying to toggle individual PORTs (by writing it P0 = 0xff;) in my main loop, only P0.0 to P0.3 are working as they should and remaining bits are not getting high. If I write P1=0xff; then only P1.0 and P0.4-P0.7 are getting high. I think P0 should not work like this.

    Program to toggle P0:

    #include "reg24le1.h"  // I/O header file for NRF24LE1
    #include "hal_delay.h" // header file containing delay functions
    
    void main()
    {
    	P0DIR = 0x00; //output port
    	P0=0;       // set p0 initially as low
    	while(1)
    	{
    	    P0=0xff;         //set P0 high
    	    delay_ms(1000);
    	    P0=0x00;         // set P0 low
    	    delay_ms(1000);
    	}
    	

    Program to toggle P1:

    #include "reg24le1.h"  // I/O header file for NRF24LE1
    #include "hal_delay.h" // header file containing delay functions
    
    void main()
    {
    	P1DIR = 0x00; //output port
    	P1=0x00;
    	while(1)
    	{
    	    P1=0xff;
    	    delay_ms(1000);
    	    P1=0x00;
    	    delay_ms(1000);
    	}
    }

Children
Related