nRF24LE1 - First program - Help needed

Questions for programming 8051 microcontrollers in C or assembly using SDCC

nRF24LE1 - First program - Help needed

Postby Viking » Mon Feb 17, 2014 1:18 am

Hi, I'm having trouble getting my nRF24LE1 to work. I'm new to SDCC, codeblocks and the nRF24LE1 since I come from the Propeller world but I was hopping someone could help me out with my first program for this module.

I managed to get the following code which uses brennen's SDK to compile and link but I'm not sure it's ok.
Code: Select all
#include <stdio.h>
#include "reg24le1.h"
#include "gpio.h"
#include "delay.h"

void initialize();

#define led_on()      gpio_pin_val_set(P0_SB_D3)
#define led_off()      gpio_pin_val_clear(P0_SB_D3)

void main()
{
   //unsigned int count; //counter for for loop

   initialize(); //initialize IO, UART, set up nRF24L01 as TX

   //main program loop
   while(1)
   {
      led_on();
      delay_ms(300); //wait for remote unit to come from standby to RX
      led_off();
      delay_ms(500);
   }
}

void initialize()
{
   //Set up LED pin
   gpio_pin_configure(GPIO_PIN_ID_P0_3,
                  GPIO_PIN_CONFIG_OPTION_DIR_OUTPUT |
                  GPIO_PIN_CONFIG_OPTION_OUTPUT_VAL_CLEAR |
                  GPIO_PIN_CONFIG_OPTION_PIN_MODE_OUTPUT_BUFFER_NORMAL_DRIVE_STRENGTH);

}


My .ihx file is 7K long with 1665 bytes of payload
I'm using 32 pin version of the module and I included all the src files in the codeblocks project. So far the build gives a no-errors result.
I know the module is correctly burned from the .ihx file since I can read de flash and verified it has the files content.

I don't see the pin toggling.

Can someone point me to where i have the error?

thanks
Alex
Viking
 
Posts: 5
Joined: Mon Feb 17, 2014 1:06 am

Re: nRF24LE1 - First program - Help needed

Postby brennen » Mon Feb 17, 2014 1:06 pm

That code looks like it should work. What version of SDCC are you compiling with? Run "sdcc -v" (no quotes) at the command line and it will print this out for you.
brennen
Site Admin
 
Posts: 395
Joined: Sun Aug 17, 2008 2:15 pm

Re: nRF24LE1 - First program - Help needed

Postby Viking » Mon Feb 17, 2014 7:40 pm

This is my SDCC version,

Code: Select all
C:\Nordic\SDK\Blink>sdcc -v
SDCC : mcs51/z80/z180/r2k/r3ka/gbz80/tlcs90/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8 3.3.2 #
8938 (Jan 24 2014) (MINGW64)
published under GNU General Public License (GPL)


but I think I have problems with my Code-Blocks settings. This is my .lk file and I believe I should have main.rel as the first element.
Code: Select all
-muwx
-i bin\Release\Blink.ihx
-M
-Y
-C 0x8000
-b HOME = 0x0000
-b ISEG = 0x0000
-b BSEG = 0x0000
-k C:\Program Files\SDCC\lib
-k C:\Program Files\SDCC\bin\..\lib\large
-l mcs51
-l libsdcc
-l libint
-l liblong
-l libfloat
obj\Release\src\delay\src\delay_ms.rel
obj\Release\src\delay\src\delay_s.rel
obj\Release\src\delay\src\delay_us.rel
obj\Release\src\gpio\src\gpio_pin_configure.rel
obj\Release\src\gpio\src\gpio_pin_dir_input.rel
obj\Release\src\gpio\src\gpio_pin_dir_output.rel
obj\Release\src\gpio\src\gpio_pin_val_clear.rel
obj\Release\src\gpio\src\gpio_pin_val_complement.rel
obj\Release\src\gpio\src\gpio_pin_val_read.rel
obj\Release\src\gpio\src\gpio_pin_val_set.rel
obj\Release\src\gpio\src\gpio_pin_val_write.rel
obj\Release\main.rel

-e


Can anyone tell me how do I change codeblocks to put my main.rel entry as the first one?

Alex
Viking
 
Posts: 5
Joined: Mon Feb 17, 2014 1:06 am

Re: nRF24LE1 - First program - Help needed

Postby Viking » Tue Feb 18, 2014 4:23 am

After changing the weight for main.c, I was able to link in the correct order. However it still doesn't flash the output as it should..

Any pointers are welcome.

Even better if someone is so kind to compile and make it work I would greatly appreciate knowing the right compile/link flags used..

Thanks in advance.

Alex
Viking
 
Posts: 5
Joined: Mon Feb 17, 2014 1:06 am

Re: nRF24LE1 - First program - Help needed

Postby brennen » Tue Feb 18, 2014 12:59 pm

Is there any particular reason you're not just using the provided makefile? It should build and link everything properly. You just need to have your project and the library under the same parent folder. Build your application with make -s all at the command line from the top-level folder within the application.
brennen
Site Admin
 
Posts: 395
Joined: Sun Aug 17, 2008 2:15 pm

Re: nRF24LE1 - First program - Help needed

Postby Viking » Tue Feb 18, 2014 4:22 pm

brennen wrote:Is there any particular reason you're not just using the provided makefile? It should build and link everything properly. You just need to have your project and the library under the same parent folder. Build your application with make -s all at the command line from the top-level folder within the application.


Well, it's been a while since I used make and I was starting out with codeblocks (under windows). I'm not sure the make utility I downloaded is the right one (see below) and I didn't fully understand the makefiles included in the SDK.

I just tried copying my main.c to the root dir of the SDK (where _target*, src and include dirs are located). It didn't work, this is the result:
Code: Select all
C:\Nordic\SDK>make all
process_begin: CreateProcess(NULL, ls -d _target*, ...) failed.
makefile:3: *** There are no targets to clean/build.  Stop.

C:\Nordic\SDK>make -v
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i386-pc-mingw32


Thanks for your support
Alex
Viking
 
Posts: 5
Joined: Mon Feb 17, 2014 1:06 am

Re: nRF24LE1 - First program - Help needed

Postby brennen » Tue Feb 18, 2014 6:49 pm

You'll need to download Cygwin if you're using Windows with the full development package. Native Windows versions of "make" don't like my makefiles because of backslashes for whatever reason. You'll also want to put the cygwin\bin folder first in your PATH variable (Cygwin's install utility doesn't do this for whatever reason, as I recall).
brennen
Site Admin
 
Posts: 395
Joined: Sun Aug 17, 2008 2:15 pm

Re: nRF24LE1 - First program - Help needed

Postby Viking » Fri Feb 21, 2014 7:43 pm

I found it!!!

My original program was flawed...where it say's
Code: Select all
#define led_on()      gpio_pin_val_set(P0_SB_D3)
#define led_off()      gpio_pin_val_clear(P0_SB_D3)


it should really say
Code: Select all
#define led_on()      gpio_pin_val_set(GPIO_PIN_ID_P0_3)
#define led_off()      gpio_pin_val_clear(GPIO_PIN_ID_P0_3)


Although the original program compiled without warnings, it's NOT the same (P0_SB_D3 is a bit address, GPIO_PIN_ID_P0_3 is an enumeration).

Finally got it working.
Thanks for the support.
Alex
Viking
 
Posts: 5
Joined: Mon Feb 17, 2014 1:06 am

Re: nRF24LE1 - First program - Help needed

Postby brennen » Mon Feb 24, 2014 2:41 pm

Ah that's an easy one to overlook. I'm glad you got it working!
brennen
Site Admin
 
Posts: 395
Joined: Sun Aug 17, 2008 2:15 pm


Return to 8051 Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron