This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Using ROM_ function

I'm trying to use ROM_ functions to initialize the following code:

#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
#include "driverlib/rom.h"
#include "driverlib/rom_map.h"
#include "gets.h"

#define BUFFER_SIZE 39

uint32_t ui32SysClkFreq;

int main(void)
{
	char string_[BUFFER_SIZE+1];
	uint32_t ui32strLen;

	ui32SysClkFreq = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
		  SYSCTL_OSC_MAIN | SYSCTL_USE_PLL |
			SYSCTL_CFG_VCO_480), 120000000);

	//
	// Configure the appropriate pins as UART pins; in this case, PA0/PA1 are
	// used for UART0.
	//
	ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
	ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);

	ROM_GPIOPinConfigure(GPIO_PA0_U0RX);
	ROM_GPIOPinConfigure(GPIO_PA1_U0TX);

	ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
	//
	// Initialize the UART standard IO module, when using an 80 MHz system
	// clock.
	UARTStdioConfig(0, 115200, ui32SysClkFreq);
	//
	// Print a string.
	//
	UARTprintf("HELLO\r\n");

	while(1){
		if (UARTCharsAvail(UART0_BASE)) {
			ui32strLen = UARTgets(string_, BUFFER_SIZE+1);
			if (ui32strLen == (BUFFER_SIZE+1)) {
				string_[BUFFER_SIZE] = '\0';
			}
		UARTprintf("String: %s \r\n", string_);
		}
	}
}

but when i try to build i get the following errors:

If I remove the ROM_ before the functions or change it to MAP_ the code compiles and runs without any problem.

What do I have to do to use those functions?

  • Hello Leonardo,

    Since you may be using a TM4C1294x device, you need to add the define TARGET_IS_TM4C129_RA1 during compilation.

    Regards
    Amit
  • Thank you one more time, Amit. Problem solved.
    To be honest, I read the guide for driverlib but I could not understand really the difference between ROM_ and MAP_ functions. Do you know when I need to use them?
  • Hello Leonardo,

    The MAP_ function when used along with the defines allow the application to use the ROM_ API's when they are available, else place the APIn in flash. So if the application code has all API being called from ROM via the use of MAP, then it saves flash space, as the code for the API does not need be kept in the Flash.

    The ROM_ must only be used if you are 100% sure that the you will never need to use the Flash API. Also the drawback of making a ROM call is that if there is an issue with the ROM API, and the TivaWare software automatically deprecates the ROM API then your application with a recompile shall not be able to benefit out of the auto-deprecate.

    Regards
    Amit
  • Hi Amit.

    I am a little unclear.

    When you say "The ROM_ must only be used if you are 100% sure that the you will never need to use the Flash API", by Flash-API you mean the functions stored in the Flash, or the APIs that are used to access the Flash?

    Just curious, so as to avoid any future issues in our code :P

    Thanks and Regards,

    Ajay

  • Hello Ajay

    The same function stored in the Flash.

    Regards
    Amit
  • Thanks Amit.

    One last question, would mixing the usage of functions with-ROM_ and without ROM_, result in subtle, hard-to-find errors?
    Or avoiding the mixing is just a good practice/recommendation?

    Again, asking because, unfortunately right now we have inconsistent usage of ROM_-functions and the "normal"-counterparts (even for same functions, sometimes we have used the "normal" versions, and sometimes the ROM_-counterparts).

    Right now, things are working fine with about 3 months of testing, but would love to gain more insight through your expertise.

    Thanks and Regards,
    Ajay
  • Hello Ajay

    Don't mix. Instead use the MAP_ . This allows the functions to be mapped to ROM or mapped to Flash based on the fact that the function is available in ROM or not. Also if there is an issue because of which the ROM function is not to be used, we can deprecate it in the rom_map file allowing a recompile (w/o search and replace) to get a new out file quickly.

    Regards
    Amit
  • Thanks Amit.

    I get your point, and I am already beginning to work as per your recommendations.

    However, we have some devices deployed at (fairly remote locations in) field.

    So, if the (current) mix of ROM_ and without-ROM_ functions is not an error, then it would be a great peace of mind for us (in the sense that we will not have to recall these devices). 


    As of now, the current (small number of) deployed devices are working perfectly, with no issue observed whatsoever in any of the device.


    Would love to hear your expert insights.

    Thanks and Regards,

    Ajay

  • Hello Ajay,

    The errata document should cover such scenarios and in this case you must check the latest version of the errata and evaluate it. A failure that has not occurred so far does not mean that there is no latent failure.

    Regards
    Amit