What causes LowPowerTimer to crash during instantiation? - mbed

Upon instantiating a LowPowerTimer, like so:
LowPowerTimer* lowPowerTimer = new LowPowerTimer();
It crashes on my own target. It works 100% on the STM32F429-discovery evaluation board.
What could cause the problem? All other code runs perfectly. There are enough memory and flash. The micro is of the same family. Are there any prerequisites that I do not know of? The micro I'm using is the STM32F413RH with a 26MHz external crystal.
I use the mbed platform and code in C++, FWIW...

My first guess would be that you have not configured the lpticker clock source correctly. Do you have the same crystals as the evaluation board? See which clock source the lpticker is using there and see if it's missing on your final board.
In addition, what is crashing? Do you see a hard fault? Where does it originate from?

So what I found was that in the targets.json file I had to override the lse_available macro. The lse_available macro states that a low-speed external oscillator is connected to the micro - and then the Low Power Ticker would use that as its source. But if you set it to 'not connected', it uses other clock sources.

Related

Cannot write to STM32 (Cortex M4) ISERx, STIR Register

I am trying to manually set the ISER0 and STIR registrs to invoke interrupt number 3 which is RTC Wakeup Interrup for educational purposes. Here is my code:
I step through the register contents, but somehow the code was not able to write to the ISER0 and STIR registers, as is shown below where i am trying to clear the ISER0 register.
Can someone please explain me what am i doing wrong here?
ISER has one bit for every exception, STIR takes exception number - 16.
In the second image you write 0 to the ISER register. That has no effect as described from both ARM architecture reference manual and STM32 M4 Programming Manual.
I would put a volatile on both register pointers declaration, but in this case I don't think it's an issue.
The issue is solved. Somehow, the stlink debug with openOCD was causing an issue with semihosting enabled to which i have no explanation for now. When I changed the debugging to STLink with SWV viewer, it worked ok...

Writing and Loading Code from QSPI Flash Memory from RP2040

I bought an RP2040 board with 16MB QSPI Flash Memory in the board:
The Flash Memory w25q128 is connected to QSPI dedicated pins of the RP2040:
I was finding out how to access this data from the RP2040 datasheet:
But I didn't find out how to:
Initialize XIP memory in rp2040 boot;
To flash/access data into the w25q128; and
Run instructions from the External Flash Memory.
I was looking for sample codes at GitHub but I didn't find anything useful for these two items I want.
I also found the 2.6.3.1 section of the RP2040 datasheet but I don't know if XIP cache is what I am looking for...
Does someone have done anything related to that? I am a newbie in this subject, so I would like to sorry if I did something wrong.
Thanks in advance!
In the datasheet there is an hint that this configuration is done by the SDK automatically if certain conditions are met:
Following the github link we get to the assembly source for the second stage bootloader. This answers the question on how to initialize the memory. It's not done by you (unless you are not using the SDK).
Here are the configuration steps:
SSI stands for Synchronous Serial Interface and it's what has to be configured to use the flash as XIP. It's described in the datasheet:

Using Vector Offset table with MBED library on Eclipse IDE

I'm a newly graduated electronics engineer and one of my first tasks in my new job is to import a code to Mbed compiler.
I'm trying to run the Mbed Blinky example on my custom hardware with LPC1769 chip. I've exported the Blinky app to GNU Eclipse from the Online MBED compiler and imported it to the IDE.
The Mbed blinky code runs fine when I set the appropriate led pin(changing LED1 in the PinNames.h from 1.10 to 2.13 for my hardware) and flash it directly. So MBed and my custom HW isn't problematic. However, my firm has a custom bootloader and it's required to use it with any application. The custom bootloader requires that I start the program beginning from 0x4000.
For this my firm was previously adding this line to their code, flashing the bootloader and uploading the IDE's output .bin file to the board with a custom FW loading program.
SCB->VTOR = (0x4000) & 0x1FFFFF80;
When I try to follow the same steps, compiler builds without any complaints, but I see no blinks when I upload the program to my bootloader.
I'm suspecting I have to make some changes to the built-in CMSIS library, and/or the startup_LPC17XX.o and system_LPC17xx.o files come with the MBED export, but I'm confused. Any help would be much appreciated.
Also, I'm using the automatically built make file, in case there's any wonders.
Most importantly, you need to adjust the code location in the linker script, for example:
MEMORY {
FLASH : ORIGIN = 0x4000, LENGTH = 0x7C000
}
Check the startup code and linker script for any further absolute addresses in flash memory.
Adjusting the VTOR is required for interrupts, if the bootloader doesn't already do that. The & operation looks weird; it should be sufficient to simply write 0x4000, or, even better, something like:
SCB->VTOR = (uint32_t) &_IsrVector;
Assuming you have defined _IsrVector in your linker script or startup code to refer to the very first byte in the vector table, i.e. the definition of the initial stack pointer. This way you don't have to adjust the code if the memory layout is changed in the linker script, and you avoid magic numbers.

STM32 HAL DMA interrupt does not fire

I'm doing an STM32 HAL course.
In the section "Direct Memory Access (DMA)", the interrupt doesn't get fired on completion of the DMA transfer.
In polling mode all works fine.
I use a Nucleo-F746ZG, my code is on github: https://github.com/bkht/STM32-HAL-DMA-Interrupt
What could I check to fix this?
When setting up the callback function, does it need to go before calling HAL_DMA_Init?
Or can it be done just before starting the DMA transfer with HAL_DMA_Start?
Also, I do see the & sometimes, referring to the function address, I tried it, but it didn't make a difference.
What should be used, & or not?
/* Setup callbacks, not sure this can be done without HAL_DMA_Init */
hdma_memtomem_dma2_stream0.XferCpltCallback = &XferCpltCallback;
Pulling #jacobq comment into an answer.
There is currently a bug in the CubeMX autogenerated code where the MX_DMA_Init() is called in the wrong order.
The proposed solution is to edit the ioc file, where it lists the function order.
This is needed because the CubeMX software (in Project Manager > Advanced Settings) locks the position of the MX_DMA_Init generated function call unhelpfully!

How can my vhdl code and microblaze co-exist?

Well my problem stated when i had my vhdl code up and running on my Spartan-3a but needed to send and receive data from it to the pc,
I need my vhdl code , so i went for a microplaze structure , problem is I cant understand how will my vhdl code and microblaze co-exist at the same time because every time i program fpga with SDK it deletes my vhdl off the fpga and vise versa with ISE, I dont want to use custom peripherals except if this is the only solution.
Some people just tell me to just use microblaze hdl files produced by EDK, OK but theny aren't I using an unprogrrammed MicroBlaze???
And do i need to go through all of this just to be able to communicate with my vhdl code through pc(NO I CANT USE R232 since i need a speed of 56Mbit/sec)
So here is what i don't understand:
1-IF you implemented microblaze through hardware(HDL from edk to ISE) , isnt it then an un-proggrammed processor?
2-PEOPLE TELL ME i can let microblaze and my vhdl code see each other through GPIO , again how will i implement GPIO and how to connect it to both microblaze and my vhdl code , and how to program microblaze while it in hardware in this situation.
Please any help , its kinda a mess.
It is not that difficult, but unfortunately Xilinx documentation is not that clear.
What you need to do after you are done with your Microblaze code and you feel comfortable with it, is to create a new project in ISE or the one you already had, then add a new file to the project, but instead of adding a VHDL or Verilog file, you must add the system file from EDK.
After you added your XPS project into ISE, you need to do some manual work in order to make things work for you.
Here are a list of things that needs to be done:
You have to create a UCF file that includes all the constraints from EDK
You have to make sure that you have enough space inside your FPGA for both the EDK and
your own code
Synthesize and implement your design using the project in ISE.
Program your FPGA from the bit file generated by ISE
In order to communicate between the MB and your own code, you can do it in many different ways, the easiest way is to use the GPIO block from your MB, then connect those signals to your own code on your top level wrapper.
You maybe able to find some useful information on the lab document and lab material from the following Xilinx page:
enter linkXilinx EDK interface class description here
Accessing the GPIO is pretty simple, you can use the information on this page to get you started:
Reading DIP Switch with MicroBlaze
You may also find this document and related files very useful, it is not for your board, but it covers the exact same thing you are asking for:
Avnet MB tutorial document
I hope this is clear enough.