Hi,
1. I can't find calloc or malloc within stdlib.h from MikroElektronika, are there implentations in different libs?
2. Next question is about interrupts. I tried to implement an interrupt like shown in the help file. But I get the following compilation error: \main.c,53): Undeclared identifier 'NVIC_IntEnable' in expression.
How is the NVIC_IntEnable() implementation in mikroSDK2 or mikroSDK2.0.1? Seems that the helpfile shows how to use interrupts the "legacy way".
I appreciate your input.
calloc, malloc and interrupts... necto AI ARM
Re: calloc, malloc and interrupts... necto AI ARM
Hi,
Malloc is implemented in the Memory Manager library, available for legacy projects.
Regards,
Filip.
Code: Select all
1. I can't find calloc or malloc within stdlib.h from MikroElektronika, are there implentations in different libs?
The NVIC_xyz functions are declared in legacy libraries, mixing the mikroSDK 2.0 and legacy stuff is something that is not recommended.2. Next question is about interrupts. I tried to implement an interrupt like shown in the help file. But I get the following compilation error: \main.c,53): Undeclared identifier 'NVIC_IntEnable' in expression.
How is the NVIC_IntEnable() implementation in mikroSDK2 or mikroSDK2.0.1? Seems that the helpfile shows how to use interrupts the "legacy way".
Regards,
Filip.
Re: calloc, malloc and interrupts... necto AI ARM
Hi Filip,
So I have the same question - all the code examples use functions like NVIC_xxxx - or even just Enable_Interrupts(), both of which cause compiler errors. If I use the code generated by the Timer Calculator - it won't compile.
What is the workaround? How do we enable interrupts please?
Thanks!
So I have the same question - all the code examples use functions like NVIC_xxxx - or even just Enable_Interrupts(), both of which cause compiler errors. If I use the code generated by the Timer Calculator - it won't compile.
What is the workaround? How do we enable interrupts please?
Thanks!
Re: calloc, malloc and interrupts... necto AI ARM
Hi,
Are you using mikroSDK or legacy project ?
Regards,
Filip
Are you using mikroSDK or legacy project ?
Regards,
Filip
Re: calloc, malloc and interrupts... necto AI ARM
Well, the question is:
How can we use interrupts with mikroSDK?
Regards
anubis
How can we use interrupts with mikroSDK?
Regards
anubis
Re: calloc, malloc and interrupts... necto AI ARM
Try these - they directly manipulate the interrupt registers. I could get them to happily flash an LED on a timer tick. However - I'm not having as much fun with the UART interrupts
If you replace the call from the Timer Calculator to these, it should just work. The code's a bit clunky but hey, it works
Best,
R
#include "board.h"
#include "drv_port.h"
///@brief NVIC Enable
void RW_NVIC_EnableIRQ(int IRQn)
{
int bitpos = IRQn-16;
uint32_t bit_pattern = (uint32_t)(1UL << (((uint32_t)bitpos) & 0x1FUL));
uint32_t offset = (((uint32_t)IRQn) >> 5UL);
if ((int32_t)(IRQn) >= 0)
{
if(bitpos<32)
NVIC_ISER0 = bit_pattern;
else if(bitpos<64)
NVIC_ISER1 = bit_pattern;
else if(bitpos<96)
NVIC_ISER2 = bit_pattern;
}
}
///@brief NVIC Disable
void RW_NVIC_DisableIRQ(int IRQn)
{
int bitpos = IRQn-16;
uint32_t bit_pattern = (uint32_t)(1UL << (((uint32_t)bitpos) & 0x1FUL));
uint32_t offset = (((uint32_t)IRQn) >> 5UL);
// bit_pattern = 0xffffffff;
if ((int32_t)(IRQn) >= 0)
{
if(bitpos<32)
NVIC_ICER0 = bit_pattern;
else if(bitpos<64)
NVIC_ICER1 = bit_pattern;
else if(bitpos<96)
NVIC_ICER2 = bit_pattern;
}
}
If you replace the call from the Timer Calculator to these, it should just work. The code's a bit clunky but hey, it works
Best,
R
#include "board.h"
#include "drv_port.h"
///@brief NVIC Enable
void RW_NVIC_EnableIRQ(int IRQn)
{
int bitpos = IRQn-16;
uint32_t bit_pattern = (uint32_t)(1UL << (((uint32_t)bitpos) & 0x1FUL));
uint32_t offset = (((uint32_t)IRQn) >> 5UL);
if ((int32_t)(IRQn) >= 0)
{
if(bitpos<32)
NVIC_ISER0 = bit_pattern;
else if(bitpos<64)
NVIC_ISER1 = bit_pattern;
else if(bitpos<96)
NVIC_ISER2 = bit_pattern;
}
}
///@brief NVIC Disable
void RW_NVIC_DisableIRQ(int IRQn)
{
int bitpos = IRQn-16;
uint32_t bit_pattern = (uint32_t)(1UL << (((uint32_t)bitpos) & 0x1FUL));
uint32_t offset = (((uint32_t)IRQn) >> 5UL);
// bit_pattern = 0xffffffff;
if ((int32_t)(IRQn) >= 0)
{
if(bitpos<32)
NVIC_ICER0 = bit_pattern;
else if(bitpos<64)
NVIC_ICER1 = bit_pattern;
else if(bitpos<96)
NVIC_ICER2 = bit_pattern;
}
}
Re: calloc, malloc and interrupts... necto AI ARM
Hi,
Currently, the interrupt mechanism via NVIC_ functions is not supported, we are planning to introduce it in one of the next releases of NECTO.
Regards,
Filip.
Currently, the interrupt mechanism via NVIC_ functions is not supported, we are planning to introduce it in one of the next releases of NECTO.
Regards,
Filip.
Re: calloc, malloc and interrupts... necto AI ARM
Hi,
since the last post, has any interrupt mechanism (NVIC_ functions) been implemented for MikroC AI. I'm trying to use interrupts on STM32F407VG (Clicker 2)
Is it still needed to enable interrupts directly trough registers?
Code example:
There is an error undeclared identifier for NVIC_IntEnable and EnableInterrupts, but also for GPIO_Digital_Input
Built_in.h doesn't contain any of these functions.
Any help is appreciated
since the last post, has any interrupt mechanism (NVIC_ functions) been implemented for MikroC AI. I'm trying to use interrupts on STM32F407VG (Clicker 2)
Is it still needed to enable interrupts directly trough registers?
Code example:
Code: Select all
void Init_Interrupt()
{
// Pin configuration
GPIO_Digital_Input(&GPIOD_BASE, _GPIO_PINMASK_0);
// Pin interrupt
SYSCFGEN_bit = 1; // Enable clock for alternate pin functions
SYSCFG_EXTICR1 |= 0x0003; // PD_0
EXTI_IMR |= 0x00000001; // Set mask
EXTI_RTSR |= 0x00000001; // Set interrupt on Rising edge
EXTI_FTSR |= 0x00000000; // Set Interrupt on Falling edge
NVIC_IntEnable(IVT_INT_EXTI0); // Enable External interrupt
EnableInterrupts();
}
void Do_Interrupt_EXTI0() iv IVT_INT_EXTI0 ics ICS_AUTO
{
if ((EXTI_PR & 0x00000001) != 0)
{
// Interrupt code
EXTI_PR |= 0x00000001 ; // Clear PD_0 trigger
}
}
Built_in.h doesn't contain any of these functions.
Any help is appreciated
Re: calloc, malloc and interrupts... necto AI ARM
Hi,
I'm afraid this hasn't been implemented yet.
Regards,
Filip.
I'm afraid this hasn't been implemented yet.
Regards,
Filip.