You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried to copy a function from flash to ram in cc2650 launchpad. When it redirects to new address in RAM, the function is not called. Here is my code.
In linker script, RAM is configured with RWX, allowing code to be executed. I read document cc2650 and it allows RAM execution. https://www.ti.com/lit/ds/symlink/cc2650.pdf
// Example function to be copied to RAM
void test_function(void) {
printf("Function running from RAM\n");
}
// Function to copy test_function to RAM and execute it
void run_from_ram(void) {
void (*ram_function)(void);
// Allocate space in RAM
uint32_t *ram_space = (uint32_t *)0x20000100; // Example RAM address
// Copy function to RAM
memcpy(ram_space, (void *)&test_function, 100); // Adjust size as needed
// Cast RAM space to a function pointer and call it
ram_function = (void (*)(void))ram_space;
ram_function(); // **not redirecting to new address??????**
}
int main(void) {
printf("Starting program...\n");
// Run the test function from RAM
run_from_ram();
printf("Program finished.\n");
return 0;
}
The text was updated successfully, but these errors were encountered:
Hi guys,
I tried to copy a function from flash to ram in cc2650 launchpad. When it redirects to new address in RAM, the function is not called. Here is my code.
In linker script, RAM is configured with RWX, allowing code to be executed. I read document cc2650 and it allows RAM execution. https://www.ti.com/lit/ds/symlink/cc2650.pdf
This problem from Contiki-ng or MPU, MCU?
#include <stdio.h>
#include <string.h>
#include <stdint.h>
// Example function to be copied to RAM
void test_function(void) {
printf("Function running from RAM\n");
}
// Function to copy test_function to RAM and execute it
void run_from_ram(void) {
void (*ram_function)(void);
// Allocate space in RAM
uint32_t *ram_space = (uint32_t *)0x20000100; // Example RAM address
}
int main(void) {
printf("Starting program...\n");
}
The text was updated successfully, but these errors were encountered: