Clear Filters
Clear Filters

Info

This question is closed. Reopen it to edit or answer.

error: initializer element is not constant (void (*)(void))​((uint32_t​)&__STACK_​TOP)

1 view (last 30 days)
Hello;
I'm using the CCS C code for serial transmit from my Tiva C launchpad.
The C code works fine, but when I pass it to a function block in Simulink by code.ceval, during the debug I receive this error:
:\Users\Alberto\Desktop\startup_ccs.c:71:22: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
(void (*)(void))((uint32_t)&__STACK_TOP),
^
C:\Users\Alberto\Desktop\startup_ccs.c:71:5: error: initializer element is not constant
(void (*)(void))((uint32_t)&__STACK_TOP),
^
C:\Users\Alberto\Desktop\startup_ccs.c:71:5: error: (near initialization for 'g_pfnVectors[0]')
gmake: *** [startup_ccs.obj] Error -1
I can't understand the error, this is my C code of the main:
#include <stdint.h>
#include <stdio.h>
#include <stdbool.h>
#include <math.h>
#include "hw_ints.h"
#include "hw_memmap.h"
#include "debug.h"
#include "fpu.h"
#include "gpio.h"
#include "interrupt.h"
#include "pin_map.h"
#include "rom.h"
#include "sysctl.h"
#include "uart.h"
#define GPIO_PA0_U0RX 0x00000001
#define GPIO_PA1_U0TX 0x00000401
char car[2000];
double u;
void UARTSend2(const uint8_t *pui8Buffer, uint32_t ui32Count);
//*****************************************************************************
// Send a string to the UART.
void UARTSend2(const uint8_t *pui8Buffer, uint32_t ui32Count)
{
while(ui32Count--) // Loop while there are more characters to send.
{
ROM_UARTCharPutNonBlocking(UART0_BASE, *pui8Buffer++); // Write the next character to the UART.
}
}
//*****************************************************************************
// This example demonstrates how to send a string of data to the UART.
int
main(double u)
{
ROM_FPUEnable(); // Enable lazy stacking for interrupt handlers. This allows floating-point
ROM_FPULazyStackingEnable(); // instructions to be used within interrupt handlers, but at the expense of extra stack usage.
ROM_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); // Set the clocking to run directly from the crystal.
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); // Enable the GPIO port that is used for the on-board LED.
ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2); // Enable the GPIO pins for the LED (PF2).
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); // Enable the peripherals used by this example.
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
ROM_IntMasterEnable(); // Enable processor interrupts.
GPIOPinConfigure(GPIO_PA0_U0RX); // Set GPIO A0 and A1 as UART pins.
GPIOPinConfigure(GPIO_PA1_U0TX);
ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
ROM_UARTConfigSetExpClk(UART0_BASE, ROM_SysCtlClockGet(), 115200, // Configure the UART for 115,200, 8-N-1 operation.
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
UART_CONFIG_PAR_NONE));
u=1234;
int cont=(log10(u))+6;
sprintf (car,"%.2f\r\n",u);
UARTSend2((uint8_t *) car,cont); // Prompt for text to be entered.
}
And this is the code from the file that receive the error:
...
#pragma DATA_SECTION(g_pfnVectors, ".intvecs")
void (* const g_pfnVectors[])(void) =
{
(void (*)(void))((uint32_t)&__STACK_TOP),
// The initial stack pointer
ResetISR, // The reset handler
NmiSR, // The NMI handler
FaultISR, // The hard fault handler
....
Can you help me to find the solution?
Thanks

Answers (1)

Venkatachala Sarma
Venkatachala Sarma on 6 May 2016
Hi Alberto,
Could you paste your MALTAB coder in the MATLAB Function block here?

This question is closed.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!