2009-01-26 09:22 PM
unable to set bit
2011-05-17 04:00 AM
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? --dave2011-05-17 04:00 AM
Did you include the ''stm32f10x_lib.h'' file?
2011-05-17 04:00 AM
indeed, that is included.
2011-05-17 04:00 AM
can you share the main.c file?
2011-05-17 04:00 AM
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 ]2011-05-17 04:00 AM
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...
2011-05-17 04:00 AM
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 ]2011-05-17 04:00 AM
See at following path:
C:\Keil\ARM\Boards\ST\STM32F10X_EVAL\Blinky C:\Keil\ARM\Boards\Keil\MCBSTM32\Blinky2011-05-17 04:00 AM
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