cancel
Showing results for 
Search instead for 
Did you mean: 

unable to set bit

dave4
Associate II
Posted on January 27, 2009 at 06:22

unable to set bit

12 REPLIES 12
dave4
Associate II
Posted on May 17, 2011 at 13:00

Hi,

I am currently unable to set a bit on GPIOB, but I can reset it - here is the line of code

GPIO_SetBits(GPIOB, GPIO_Pin_3);

and here are the error messages the Keil compiler gives me:

src\switch_output_on.c(75): error: #79: expected a type specifier

src\switch_output_on.c(75): error: #79: expected a type specifier

src\switch_output_on.c(75): error: #159: declaration is incompatible with previous ''GPIO_SetBits'' (declared at line 225 of ''.\libs\inc\stm32f10x_gpio.h'')

My line 225 it references is here:

void GPIO_SetBits(GPIO_TypeDef* GPIOx, u16 GPIO_Pin);

As far as I can see, this should work, so what am I doing wrong here?

--dave

jilisegiar
Associate II
Posted on May 17, 2011 at 13:00

Did you include the ''stm32f10x_lib.h'' file?

dave4
Associate II
Posted on May 17, 2011 at 13:00

indeed, that is included.

jilisegiar
Associate II
Posted on May 17, 2011 at 13:00

can you share the main.c file?

dave4
Associate II
Posted on May 17, 2011 at 13:00

Hi

I'd rather not if thats ok, but here is the called function

/**** Include files ****/

#include ''stm32f10x_lib.h''

#include ''stm32f10x_conf.h''

#include ''stm32f10x_it.h''

#include ''globals.h''

#include

#include ''parity.h''

void switch_output_on(void)

{

/**** Variable declaration ****/

static u8 char_count = 0; // message char count

static u8 busy_semaphore = 0; // semaphore lock for tx

u8 array_count = 0; // Array element counter

vu8 message_on_contents[14];

/**** typedefs ****/

typedef struct

{

vu8 control_dollar;

vu8 descriptor_p;

vu8 descriptor_s;

vu8 descriptor_u;

vu16 address;

vu8 space;

vu8 command_o;

vu8 command_p;

vu8 command_uscore;

vu8 command_e;

vu8 command_n;

vu8 CR;

vu8 LF;

} Send_msg_on;

Send_msg_on MsgSend_on;

/*** struct declaration ***/

MsgSend_on.control_dollar = '$';

MsgSend_on.descriptor_p = 'p';

MsgSend_on.descriptor_s = 's';

MsgSend_on.descriptor_u = 'u';

MsgSend_on.address = psu_addr;

MsgSend_on.space = 0x20;

MsgSend_on.command_o = 'o';

MsgSend_on.command_p = 'p';

MsgSend_on.command_uscore = 0x5F;

MsgSend_on.command_e = 'e';

MsgSend_on.command_n = 'n';

MsgSend_on.CR = 0x0D;

MsgSend_on.LF = 0x0A;

union message_on_union

{

vu8 message_on_contents[14];

Send_msg_on MsgSend_on;

}

/**** Switch on outputs ****/

GPIO_SetBits(GPIOB, GPIO_Pin_3);

/**** Send message ****/

MsgSend_on.address = psu_addr;

if(busy_semaphore == 0)

{

busy_semaphore = 1; // set semaphore

for(array_count=0;array_count<=14;array_count++)

{

if(USART_GetFlagStatus(USART1, USART_FLAG_TC) != RESET); // check TC flag set

{

USART_SendData(USART1, message_on_contents[array_count]); // send the set message to the UART

char_count++;

} // increment char counter

}

}

busy_semaphore = 0; // reset semaphore

}

sorry if the formatting is messed up, when I tried to used code tags, all I got was a blank message

--dave

[ This message was edited by: dave6 on 21-01-2009 10:29 ]

jj
Associate II
Posted on May 17, 2011 at 13:00

Suggestion: ''kiss'' - modify the much smaller/simpler ''blinky'' program to output to your specified pin. (or even better - several additional ''same port'' pins) This seems faster/easier method...

dave4
Associate II
Posted on May 17, 2011 at 13:00

as a slightly different way of thinking of this, how would I implement this without utilising the ST libraries, I'm beginning to think that for a simple thing like switching an IO on or off it would be more optimal to just code it without the libs.

> modify the much smaller/simpler ''blinky'' program to output to your >specified pin.

I had a look at that, thanks - but the code seems to be for the LPC2100 processor, is it the same code for the STM32, or does it require modifications?

--dave

[ This message was edited by: dave6 on 22-01-2009 10:25 ]

jilisegiar
Associate II
Posted on May 17, 2011 at 13:00

See at following path:

C:\Keil\ARM\Boards\ST\STM32F10X_EVAL\Blinky

C:\Keil\ARM\Boards\Keil\MCBSTM32\Blinky

dave4
Associate II
Posted on May 17, 2011 at 13:00

thanks for the links, one problem though, I got the following error while trying to compile the second example

Blinky.c(34): error: #20: identifier ''DMA_Channel1'' is undefined

This is line 34

DMA_Channel1->CMAR = (u32)&ADC_ConvertedValue;

--dave