/var/www/restricted/ssh/stm32/www/stm32circle/ STM CircleOS forum / undefined reference to delayms and delayus

Username:     
Password:     
             

Forum

# 1   2009-05-14 10:55:52 undefined reference to delayms and delayus

pitu82
Member
Registered: 2009-03-07
Posts: 14

undefined reference to delayms and delayus

Hi guys,
I am trying to develop an X10 Rf remote controller to control lamp modules (to turn lights and appliances on an off). I want to introduce some delays as shown in the program, but when I try to build it I get some errors "undefined reference to delay ms" and undefined reference to delayus....and also undefined reference to shiftleft .I am new to programming and would really appreciate if someone could help me in this regard.

#include <stm32f10x_lib.h>
#include "x10.h"


/************************************************************************************
*Function name: x10_sendpreamble
*Description: sends 1 for 9msec & 0 for 4.5msec
*Input: None
*Output: None
*Return :None
*****************************************************************************/
void x10_sendpreamble()
{


GPIO_WriteBit(GPIOA, GPIO_Pin_2, Bit_RESET);   
delayms(40);/* Delay before start*/
GPIO_WriteBit(GPIOA, GPIO_Pin_2, Bit_SET);
delayms(8);

GPIO_WriteBit(GPIOA, GPIO_Pin_2, Bit_RESET);
delayms(4);


}

void x10_sendbit(int thebit)
{
GPIO_WriteBit(GPIOA, GPIO_Pin_2, Bit_SET);
delayus(400);
GPIO_WriteBit(GPIOA, GPIO_Pin_2, Bit_RESET);
delayus(700);
if(thebit==0)
{
delayus(1100);
}
return;
}
void x10_sendbyte(int thebyte)
{
u8 i;
for (i=0;i<8;i++)
{
x10_sendbit(shift_left(&thebyte,1,0));
}
return;
}

void x10_send(char hc, int unit, int action)
{

int ufcbyte; // unit function code
x10_sendpreamble();
// here we set the house code
if (unit > 8) { hc=0b00000011; } else { hc=0b00000111; }

switch (unit)
{
case 'P':  hc=hc|0b11001000; break; 
case 'O':  hc=hc|0b11011000; break;
case 'N':  hc=hc|0b11101000; break;
case 'M':  hc=hc|0b11111000; break;
case 'L':  hc=hc|0b00101000; break;
case 'K':  hc=hc|0b00111000; break;
case 'J':  hc=hc|0b00001000; break;
case 'I':  hc=hc|0b00011000; break;
case 'H':  hc=hc|0b01001000; break;
case 'G':  hc=hc|0b01011000; break;
case 'F':  hc=hc|0b01101000; break;
case 'E':  hc=hc|0b01111000; break;
case 'D':  hc=hc|0b10101000; break;
case 'C':  hc=hc|0b10111000; break;
case 'B':  hc=hc|0b10001000; break;
case 'A':
default:   hc=hc|0b10011000; break;
}

x10_sendbyte(hc); x10_sendbyte(~hc); // send the house code and its inverse
// here, we set the unit and function code bits
switch (action) { // need to support dim/bright
case 0: { ufcbyte=0b10000111; break; } // on
case 1: { ufcbyte=0b10100111; break; } // off
default: { ufcbyte=0b11111111; break; } // A1on
}
switch (unit) {
case 8: { ufcbyte=ufcbyte|0b00000000; break; }
case 7: { ufcbyte=ufcbyte|0b00010000; break; }
case 6: { ufcbyte=ufcbyte|0b00001000; break; }
case 5: { ufcbyte=ufcbyte|0b00011000; break; }
case 4: { ufcbyte=ufcbyte|0b01000000; break; }
case 3: { ufcbyte=ufcbyte|0b01010000; break; }
case 2: { ufcbyte=ufcbyte|0b01001000; break; }
case 1: default: { ufcbyte=ufcbyte|0b01011000; break; }
}
x10_sendbyte(ufcbyte); x10_sendbyte(~ufcbyte); // send the unit/function code and inverse
x10_sendbit(1); // gratuitous 1 at the end…
return;
}

Offline

 

# 2   2009-05-14 11:48:32 undefined reference to delayms and delayus

Francis
Administrator
From: France-Grenoble
Registered: 2007-07-09
Posts: 890

Re: undefined reference to delayms and delayus

If you want to use CircleOS, the current application is called at a fixed frequency by the scheduler. For a long delay, you could count a certain number of call... For a shorter delay, you need to configure a timer.

Offline

 

# 3   2009-05-15 01:13:10 undefined reference to delayms and delayus

pitu82
Member
Registered: 2009-03-07
Posts: 14

Re: undefined reference to delayms and delayus

Hi francis, thanks for your reply appreciate it. Actually, I am using GPIO pin 7 to enable USART2 transmission of the X10 code. So I have created a library of items. I wanted to know whether delayms and delayus functions are in built funtions or one has to declare them separately. I am sorry if I dont make sense but can you please enlighten me in this regard?

Offline

 

# 4   2009-05-15 06:12:27 undefined reference to delayms and delayus

Francis
Administrator
From: France-Grenoble
Registered: 2007-07-09
Posts: 890

Re: undefined reference to delayms and delayus

There is no such builtin functions... Are you using CircleOS ? If not, I recommend to use a timer (seems mandatory if you need to count microseconds..._.

Offline

 

# 5   2009-05-15 07:31:58 undefined reference to delayms and delayus

pitu82
Member
Registered: 2009-03-07
Posts: 14

Re: undefined reference to delayms and delayus

Hi francis, appreciate your help.....
Yes I am using Circle OS

1) Do I need to configure a timer still for the delay in microseconds.
2) Can you please elaborate..... on how do I go ahead.. I didint quite understand how to give the delay.......

Offline

 

# 6   2009-05-15 08:31:03 undefined reference to delayms and delayus

Francis
Administrator
From: France-Grenoble
Registered: 2007-07-09
Posts: 890

Re: undefined reference to delayms and delayus

Ok. In CircleOS, your application will be called at a fixed frequency by CircleOS. Look at the getting started to know more about the frequency of the calls.. The simplest solution consists in counting some 'dummy calls' in your handler:

Code:

int CurrentDelay = 0;
enum MENU_code Application_Handler ( void )
  {
  if ( CurrentDelay!=0 )
     {
      --CurrentDelay;
      return MENU_CONTINUE;   // Returning MENU_LEAVE will quit to CircleOS
      }
  //else we can work... 
  ....  .... 
  if ( .... )
     {
     CurrentDelay = 5; //Now setting a new delay (number of calls)
      return MENU_CONTINUE;   // Returning MENU_LEAVE will quit to CircleOS
     }

Now you can modify the frequency of the calls, and also modify the frequency of the main clock... A first solution consists in fixing these parameters in your application_ini (in this case you will have to restore the original values when exiting your application).

Note that the code above suppposes that the minimum period could be 1 tick... Don't know if this granularity is sufficent in your case. If it is not, you must manage a hardware timer in your application.

Offline

 

Board footer