I'm new with ARM processors, i recently bought STM32F4 Discovery Kit. Do you suggest me to begin proggraming with CooCoz or another IDE?
Sorry for English, Good work.
Yes, it is easy to use.
Download ST-LINK utility, CoIDE and gcc-arm-embedded toolchain.
Install it and configure CooCox. In "Project -> Select Toolchain Path" select directory with toolchain, by default "C:\Program Files\GNU Tools ARM Embedded\4.8 2013q4\bin"
Create new project, select stm32f407vg chip, then from repository select M4 CMSIS Core, CMSIS BOOT, RCC, GPIO. All needed files will be added to project tree.
Add code to main.c file
//basic headers
#include "stm32f4xx.h"
#include "stm32f4xx_gpio.h"
#include "stm32f4xx_rcc.h"
// delay function
void Soft_Delay(volatile uint32_t number)
{
while(number--);
}
int main(void)
{
//Peripherial clock setup
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
//Port setup
GPIO_InitTypeDef ledinit;
ledinit.GPIO_Mode = GPIO_Mode_OUT;
ledinit.GPIO_OType = GPIO_OType_PP;
ledinit.GPIO_PuPd = GPIO_PuPd_NOPULL;
ledinit.GPIO_Speed = GPIO_Speed_2MHz;
ledinit.GPIO_Pin = GPIO_Pin_15; //
GPIO_Init(GPIOD, &ledinit);
while(1)
{
// Led On
GPIO_SetBits(GPIOD, GPIO_Pin_15);
// Pause
Soft_Delay(0x000FFFFF);
// Led Off
GPIO_ResetBits(GPIOD, GPIO_Pin_15);
// PAuse
Soft_Delay(0x000FFFFF);
}
}
Select "Project -> Rebuild" and "Flash -> Program Download", blue led will start blink.
Related
experts.
I am new to STM32.
So I downloaded some sample code from github.
https://github.com/yohanes-erwin/stm32f103-keil
And I download the simple led blinking code of it to the STM32F103C6 developing board but it doesn't work at all.
The original program embedded on the chip had been erased successfully ( originally the led was always on and LCD screen shows some text, but now after I download the code, the led is off and screen off. So I think the downloading is successful.) but the code does not work.
When I download the original code to the chip, it works again. So I think the chip isn't broken.
I think it's because of compatibility of sample code and my chip. The sample code was written for STM32F103C8. But it was a very simple code. What is the reason?
Here is the code.
#include "stm32f10x.h"
#include "stm32f10x_rcc.h"
#include "stm32f10x_gpio.h"
void delay(unsigned int nCount);
GPIO_InitTypeDef GPIO_InitStruct;
int main (void)
{
// Enable clock for GPIOA
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
// Configure PA4 as push-pull output
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_4;
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOA, &GPIO_InitStruct);
while (1)
{
/* Toggle LED on PA0 */
// Reset bit will turn on LED (because the logic is interved)
GPIO_ResetBits(GPIOA, GPIO_Pin_4);
delay(1000);
// Set bit will turn off LED (because the logic is interved)
GPIO_SetBits(GPIOA, GPIO_Pin_4);
delay(1000);
}
}
// Delay function
void delay(unsigned int nCount)
{
unsigned int i, j;
for (i = 0; i < nCount; i++)
for (j = 0; j < 0x2AFF; j++);
}
This is probably a dumb question but I need some help : I'm trying to simply blink an LED on my STM32L073 board. The LED is connected to the PB6 pin here's my code :
#include <zephyr.h>
#include <device.h>
#include <devicetree.h>
#include <drivers/gpio.h>
void main(void)
{
const struct device *dev;
dev = device_get_binding("GPIOB");
gpio_pin_configure(dev,6,GPIO_OUTPUT);
while(1){
gpio_pin_set(dev,6,1);
k_msleep(1000);
gpio_pin_set(dev,6,0);
k_msleep(1000);
}
}
I'm using platformio with Zephyr RTOS framework
In prj.conf I do have :
CONFIG_GPIO=y
In zephyr.dts, for gpiob the label is well GPIOB so I don't understand what is wrong here, so if anyone can help me it would be great :)
I am trying to use the filesystem library from C++17 while compiling with SDK.
I used this example.
#include <string>
#include <filesystem>
int main() {
const std::string path = "/tmp/";
for (const auto & entry : std::filesystem::directory_iterator(path))
std::cout << entry.path() << std::endl;
}
I have a problem when linking the library (only while compiling with SDK, it works on Ubuntu.)
Should I enable c++17 for SDK somehow?
Or should I add stdc++fs library to the SDK?
TOOLCHAIN_TARGET_TASK_append = " libstdc++-staticdev"
I'm using Eclipse and CDT to work with the mspgcc compiler, it compiles fine, but the code view highlights all my special function registers as unresolved.
I've made a C project where the compiler is "msp430-gcc -mmcu=msp430x2012", and that's set to look for includes in /usr/msp430/include/. I've set the linker to "msp430-gcc -mmcu=msp430x2012", and that's set to look fo libraries in /usr/msp430/lib/. I've set the assembler to "msp430-as". I've told eclipse it's making an elf and I've disabled automatic includes discovery to not find the i686 libraries on my linux box (stupid eclipse!).
Here's the code:
#include <msp430.h>
#include <signal.h> //for interrupts
#define RED 1
#define GREEN 64
#define S2VAL 8
void init(void);
int main(void) {
init(); //Setup Device
P1OUT = GREEN; //start with a green LED
_BIS_SR(LPM4_bits); //Go into Low power mode 4, main stops here
return(1); //never reached, surpresses compiler warning
}
interrupt (PORT1_VECTOR) S1ServiceRoutine(void) {
//we wake the MCU here
if (RED & P1IN) {
P1OUT = GREEN;
} else {
P1OUT = RED;
}
P1IFG = 0; //clear the interrupt flag or we immidiately go again
//we resume LPM4 here thanks to the RETI instruction
}
void init(void) {
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
/*Halt the watchdog timer
P1DIR = ~S2VAL; //Set LED pins as outputs and S2 as input
P1IES = S2VAL; //interrupt on High to Low
P1IE = S2VAL; //enable interrupt for S1 only
WRITE_SR(GIE); //enable maskable interrupts
}
All the variables defines in the mspgcc includes such as P1OUT and WDTCTL show up in the problems box as "not resolved", but remember it builds just fine. I've even tried explicitly including the header file for my chip (normally msp430-gcc does this via msp430.h and the -mmcu option).
I resolved this issue by explicitly including the msp430g2553.h file
#include <msp430g2553.h>
I resolved the issue by following the instructions here
I have a Qt Project and Eclipse started with the Qt Eclipse integration program.
I am using the newest version of Qt (4.3.4), Eclipse and MinGW.
My problem is, that the Eclipse Indexer does not find stuff like printf()/fprintf()/exit()! The code compiles fine and the program runs normally!
e.g:
static void mouseHandler(int event, int x, int y, int flags, void *param)
{
switch(event) {
/* left button down */
case CV_EVENT_LBUTTONDOWN:
MousePointerPosition = cvPoint(x,y);
leftClicks = 1;
break;
/* right button down */
case CV_EVENT_RBUTTONDOWN:
fprintf(stdout, "Right button down (%d, %d).\n", x, y);
break;
/* mouse move */
case CV_EVENT_MOUSEMOVE:
break;
}
}
I included a screenshot of the directories and files I included (note: I used Qt 4.7.3 in the screenshot, shouldn't make a difference)!
Any suggestions?
Here's a link to the screenshot (I am a new user..):
screenshot