Topic : STM8 GPIO configuration problem

Forum : ST7/STM8

Original Post
Post Information Post
October 22, 2009 - 6:50am
Guest

Hi all,

I've been trying to configure the GPIO and I have a problem when I compile the project it wouldn't be able to find the "stm8s.h" library. The error message showed "can not open stm8s.h".

What I've been doing was I created a new project from Ride7 and I added the file "file GPIO_IOToggle_PollingMode\main.c". I was trying to use some of those GPIO config to use for my project but it always showed errors.

What I'd like to do is start out with some simple code to turn on 1 of the port. This is the code I wrote.

#include "stm8s.h"

#define Output (GPIOB)
#define Dimmer (GPIO_PIN_2)

void main(void)
{

/* Initialize I/Os in Output Mode */
GPIO_Init(Output, Dimmer, GPIO_MODE_OUT_PP_LOW_FAST);

while (1)
{

GPIO_WriteHigh(Output, Dimmer); // set Dimmer output high

}

}

#endif

I'd appreciate for any adivice how to make this work.

Replies
Post Information Post
+1
0
-1
October 22, 2009 - 10:32am
Guest

Hi

The compiler search the .h in the "include directories" from option "Application Options->Directories"
You can see it in the command line above the error message in "PIN("REP1;REP2;")" for instance.
You need to check that the .h file is in one of this directory.
Can you also put the cursor on the line of the include and make "CTRL+SHIFT+O" and let us know the result;

Regards,
Matloub

+1
0
-1
October 22, 2009 - 5:15pm
Guest

Thank you for your response, Matloub,

I looked on the "Options" -> "Aplication Option" -> "Directories" and in the "Include Directories" showed "$(RkitInc); $(RkitInc)\ST7.

I placed the cursor on the line of the (#include "stm8s.h") and make "CTRL + SHIFT + O", the message showed "Unable to find stm8s.h"

I looked up in the C:\Program Files\Raisonance\Ride\inc\STM8 and I can't find the .h file for STM8S103K3 since I used the STM8S103K3 processor. I just wondering if this is the cause ?

Thanks again,

+1
0
-1
October 23, 2009 - 6:27am
Guest

I created an STM8S103K3.h file in C:\Program Files\Raisonance\Ride\inc\STM8 and I tried compiling again but it still show the same error message " cannot open stm8s.h".

+1
0
-1
October 26, 2009 - 11:41am
Guest

Hi

The problem is that the file stm8s.h is not in the folder and we need to add it.

For your second trial you need to add ;$(RkitInc)\STM8 "Options" -> "Aplication Option" -> "Directories" and it should
solves the issue.

Regards,
Matloub

+1
0
-1
October 26, 2009 - 1:23pm
Guest

Where I can find the file stm8s.h in order to add in the folder ?

Also I'd been trying to figure out how to change the directory to $(RkitInc)\STM8 but it would not let me edit to "$(RkitInc)\STM8"the directory and it only let me select the directory C:\Program Files\Raisonance\Ride\inc\STM8.

Thanks again,

+1
0
-1
October 26, 2009 - 2:48pm
Guest

Hi

The file and the code come from ST library an I think in <......>\Ride\Examples\STM8\STM8SFWLib\library\inc
you can find one.

For the option include directory, there are two ways to enter paths:
- You can type in the box the path
- You can open this kind of editor by click on the browse button
In the editor you need to double click to change one string
or to make add new by clicking "new" button

Regards,
Matloub

+1
0
-1
October 27, 2009 - 5:48am
Guest

I found the file stm8s.h located at C:\Program Files\Raisonance\Ride\Examples\STM8\STM8SFWLib\library\inc.

I edited the Include directories as "$(RkitInc)\STM8" , compiled it and it wouldn't work then

I changed the Include directories to "C:\Program Files\Raisonance\Ride\Examples\STM8\STM8SFWLib\library\inc", compliled and the error message "Undefined GPIO_Pin_2" and "Incorrect EOF".

/* Includes ------------------------------------------------------------------*/
#include "stm8s.h"

/* I/Os configuration */

#define Output (GPIOB)
#define Dimmer (GPIO_PIN_2)

/* Public functions ----------------------------------------------------------*/

void main(void)
{

//u8 Leds; /* Contains which LEDs to operate */

/* Initialize I/Os in Output Mode */
GPIO_Init(Output, Dimmer, GPIO_MODE_OUT_PP_LOW_FAST);

/* Toggles LEDs */

while (1)
{

GPIO_WriteHigh(Output, Dimmer); // set Dimmer output high

}

}

What did I do wrong here ? I've been so furstrating with this start up and I hope Matloub help me to get over this.

Thanks alot,

+1
0
-1
October 27, 2009 - 9:32am
Raisonance Support Team

Hi Snake,

The ST Firmware Libraries are quite complex; They use a "header callback" trick so that some specific settings are held in your private stm8_conf.h, which is itself called by header files from the library. And your C files should include only the ST library files, not your conf file!

As this trick is not easy to handle, I recommend that:
- You check out the examples provided with Ride7, (in \Examples\STM8\REva\xxx>) which contain good usage of the ST library.
- You copy the needed ST Library files in your project directory (or, even better, in a "STLib" subdir) and use them instead of the files in the "\Examples\STM8\STM8SFWLib\", which may be modified in the future, which would possibly cause your project not to work anymore.

As Matloub explained, it is possible to add some directories that will be scanned during the project build, but (once again) you should not use "\Examples\STM8\STM8SFWLib" in there.

At this price, you will have to copy lots of the library files in your project directory, but you will not have any problems any more with missing files.

Regards,
Bruno

+1
0
-1
November 3, 2009 - 5:48am
Guest

Thanks a lot, Bruno

I copy all the necessary file like stm8s.h, stm8s_gpio.c.........in the same folder of my project folder and it's working fine.

Once again, thank you for all the support