How to add a delay function

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to add a delay function

2,565 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by daniel on Mon Dec 19 06:29:30 MST 2011
I want to send messages with a fixed delay by CAN-Bus.

this is my project:
www.appelbanaan.nl/Share/can.zip

I included the timer32.c and timer32.h from build in the project.
I included the timer32.h
and I put
Quote:
  enable_timer32(1);
  delay32Ms(1,1500);
  disable_timer32(1);


in the TX_Only_test( void ).

But it still doesn't work.
I tried it also in the blinky example and it works.
So I have no idea whats going wrong.
0 Kudos
Reply
6 Replies

2,127 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by daniel on Mon Dec 19 15:25:22 MST 2011
Thank you guys,

I added some rules to config/driver_config.h file and the errors are passed.

I have some experience with C but the last time I used it was a few years ago. So the questions should be basic but sometimes you can search a few hours for a simple thing like this :(
0 Kudos
Reply

2,127 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Rob65 on Mon Dec 19 07:39:12 MST 2011

Quote: Zero

to your driver_config.h


Darn ... The Big Z beat me again ...

They call it drivers but let's be frank; there are just too many loose ends and bugs to call these things drivers :eek:

I was stupid and grabbed the small_printf library, put it in my project and used it.
I should have known better ... nsprintf is not thread safe (but who cares) and when trying to fill a string of 9 characters it would only allow me to fill 8 (yes - that is including the Zero byte).

The guys at NXP just do not have the resources to create and test full flash drivers and libraries. They do give people without experience on the LPC1xxx controllers a way to quickly start using the controllers but that's all.

Rob

P.s: who cares? I do; I am using nsprintf() to format strings to multiple uarts and the LCD from multiple FreeRTOS tasks.
0 Kudos
Reply

2,127 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Rob65 on Mon Dec 19 07:24:46 MST 2011
Daniel,

The compiler complains - and if it does this usually means you made a mistake somewhere. let's analyze the error messages you get:


Quote:
undefined reference to 'delay32Ms'

means that the linker cannot find that function.

Now look a bit further and you will also see a warning with the same function:


Quote:
implicit declaration of function 'delay32Ms'

Oops ... it looks like the compiler had a problem here discovering the declaration in timer32.h

Open the timer32.h file and look at the code.
You will notice that all the declarations are shown with a gray background. This means that a compiler directive is preventing that code being included.

Guess what "[B][COLOR=Red]#if CONFIG_ENABLE_DRIVER_TIMER32==1[/COLOR][/B]" does :eek:

Now you have everything you need to fix the problem yourself :D

Rob
0 Kudos
Reply

2,127 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Mon Dec 19 07:22:41 MST 2011

Quote: daniel
But I'm not really familiar with the LPCXpresso development tool.


  :confused:

You're not familiar with C :eek:

Look in you timer.h and timer.c files, there are a lot #ifs like

#if CONFIG_ENABLE_DRIVER_TIMER32==1

If this blocks are grayed out, they are not used because this define isn't 1 :eek:

So just add:

#define CONFIG_ENABLE_DRIVER_TIMER32        1

to your driver_config.h :)
0 Kudos
Reply

2,127 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by daniel on Mon Dec 19 07:14:15 MST 2011
I'm sorry, I forget.

error is undefined reference to...


Quote:
D:\Documents\LPCXpresso_4.1.0_190\workspace2\can\Debug/../src/cantest.c:51: undefined reference to `enable_timer32'
D:\Documents\LPCXpresso_4.1.0_190\workspace2\can\Debug/../src/cantest.c:52: undefined reference to `delay32Ms'
D:\Documents\LPCXpresso_4.1.0_190\workspace2\can\Debug/../src/cantest.c:53: undefined reference to `disable_timer32'
./src/cantest.o: In function `main':
D:\Documents\LPCXpresso_4.1.0_190\workspace2\can\Debug/../src/cantest.c:137: undefined reference to `init_timer32'
collect2: ld returned 1 exit status
make: *** [can.axf] Error 1



But my timer32.h files are active and in the driver map.
and timer32.h is included in cantest.c

so I think it's a wrong project setting or something else.
But I'm not really familiar with the LPCXpresso development tool.
0 Kudos
Reply

2,127 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Mon Dec 19 07:09:14 MST 2011

Quote: daniel
So I have no idea whats going wrong.



And your compiler is compiling and linking this project without nagging :confused::confused:
0 Kudos
Reply