2022-02-19 10:50 AM
EDIT: (normal text: fixed/sorted out(see the new program code in the end) | in bold - still needing help)
Hi, guys! So, I just got this board yesterday and I am having some trouble.
First, the LCD doesn't go on! I plug the power supply, LD9 goes on, plugging the micro A to the computer using the STLINK USB Port, I get red at the LD12 and that's all;
I was following a tutorial on Udemy on how to blink a LED, but although the LED goes on, it doesn't blink;
I even downloaded CubeProg and did those resets to see if 'd help, but it didn't;
Another thing is: How can I completely 'turn off' CM4, so that it doesn't appear on CubeIDE, doesn't generate errors and so on?
I tried to disable it using OB, but still. Every time I create an STM32 Project on the IDE it is there on the project tree, and I'd have to setting everything up for it as well.
The code I am trying is:
#include "stm32h757xx.h"
#define GPIOKEN (1U<<10) //page 492
#define PIN6 (1U << 5)
#define LED_PIN (PIN6)
int main(void){
//enable clock access to GPIOK
RCC->AHB4ENR |= GPIOKEN;
//Set GPIOK as OP
GPIOK->MODER &=~ (3U << 12); //reset bit 12 and 13
GPIOK->MODER |= (1U << 12); //set bit 12
while(1){
//toggle PIN6
GPIOK->ODR ^= LED_PIN;
for(int i = 0; i<100000; i++){}
}
}
PS: I went to the add paths and symbols and added STM32H757xx and CORE_CM7 to the symbols and (using the CubeH7 pack) I added the include folders from Drivers\Include and from Drivers\Device\ST\STM32H7xx\Include;
The code above compiles; I get the blue LED on, but it doesn't blink;
Can you guys help me?
Did I spoil my board by software/hard/core resetting it through the CubeProg?
Why does the LCD doesn't go on? Do I have to change jumpers? Does it need program code first?
How to work only with the CM7?
The course I am following follow the bare-metal approach, hence this code;
I followed some tutorials that used the HAL Library but it just added a bunch of more stuff to the project tree, populated the main way too much; besides, I'd like to learn how to work with the registers directly; aaah, and even using the HAL tutorials on the LCD didn't go on;
PS: Yeah, may I should have got a single-core board, but it was a gift, so....
Thanks!
#include "stm32h757xx.h"
#define GPIOKEN (1U<<10) //page 492
#define PIN3 (1U << 3)
#define LED3_PIN (PIN3)
#define PIN4 (1U << 4)
#define LED4_PIN (PIN4)
#define PIN5 (1U << 5)
#define LED5_PIN (PIN5)
#define PIN6 (1U << 6)
#define LED6_PIN (PIN6)
int main(void){
//enable clock access to GPIOK
RCC->AHB4ENR |= GPIOKEN;
//Set GPIOKs as OP
GPIOK->MODER &=~ (3U << 6); //reset 7.6
GPIOK->MODER |= (1U << 6); //set 6
GPIOK->MODER &=~ (3U << 8); //reset 9.8
GPIOK->MODER |= (1U << 8); //set 8
GPIOK->MODER &=~ (3U << 10); //reset bit 11.10
GPIOK->MODER |= (1U << 10); //set 10
GPIOK->MODER &=~ (3U << 12); //reset 12.13
GPIOK->MODER |= (1U << 12); //set 12
while(1){
//toggle LED PINs
GPIOK->ODR ^= LED3_PIN;
for(int i = 0; i<1350000; i++){}
GPIOK->ODR ^= LED4_PIN;
for(int i = 0; i<1350000; i++){}
GPIOK->ODR ^= LED5_PIN;
for(int i = 0; i<1350000; i++){}
GPIOK->ODR ^= LED6_PIN;
for(int i = 0; i<1350000; i++){}
}
}
//PS: even got they blinking in sequence now ^^
Solved! Go to Solution.
2022-02-20 07:14 AM
Thanks for the explanation, MM..1; I got it.
And yes, if that's how it works, then it would be indeed a nightmare, trying to set all these registers.
Yeah, Tesla. definitely. That's far from optimal. However, I was just trying precisely see which pin does what and get the LEDs to blink, in a very simple way; I also wanted to check if the for loops were getting masked off and so on;
But I'd never to that in a real application. I work with C/C++, and although the applications there lie in a completely different area, I am a fan of optimal stuff. So, as I said, I was just trying, since I am new to this specific Embedded System context, to this STM32 series, to the dual core stuff, IDE, and so on;
But still a good input anyway. And as you said: finding the balance when it comes to optimisation/using HAL, letting the compiler do its job and so on, is the best way.
Thanks, Guys.
2022-02-20 09:30 AM
<G>
I don't have a PhD, I have a BEng in Electronics, although I was programming micro-controllers in secondary school..