This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

I need help with converting any example from Keil to SES

Hello,

I've been trying for days to convert any example from Keil to SES, I have road probably every question here on the dev zone but I am unable to fix this, I ever specially install windows on my mac to try if there it would work.

So, I have done everything from official nordic documents, I've been through several problems which I happily solve, but that I'm not able to.

I get those errors:


unplaced section: .log_dynamic_data_app [nrf_log_frontend.o], size=12, align=4

undefined symbol: __SRAM_segment_end__

undefined symbol: __start_log_const_data

undefined symbol: __start_log_dynamic_data

undefined symbol: __stop_log_const_data

I'm working on latest SEGGER, I have tried latest SDK, also 14.2 . The same errors. 

Thanks for reply

Parents
  • It seems like you are not using the correct startup code.  Startup code and linker scripts are different.  Startup code and linker script go in pair. You need to use the one made for SES.

  • Hey, I have followed instructions from here https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/segger-embedded-studio-a-cross-platform-ide but its a little bit outdated since now there is SES 4.50.

    Maybe there is a tutorial of how to rewrite programs from Keil to SES? Please like, I have spent so much hours for that, everyone seems get it done, and I am unable to transfer even Blinky example... 

  • Okay never mind, I managed to solve this, and the gyro is working fine, Thanks. 

  • How now get the values from magnetometer since I got gyro and accel working?

    in Hardware init, this function:

    if (res == true)
    	{
    		res = g_MotSensor.Init(s_MagCfg, &g_I2c, &g_Timer);
    		if (res == true)
    		{
    			g_pMag = &g_MotSensor;
    		}
    	}


    makes res false

    this is my whole code

    /**-------------------------------------------------------------------------
    @example	mot_sensor_demo.cpp
    
    
    @brief	Motion sensor demo
    
    	This application demo shows UART Rx/Tx over BLE custom service using EHAL library.
    
    @author	Hoang Nguyen Hoan
    @date	Dec. 21, 2018
    
    @license
    
    Copyright (c) 2018, I-SYST inc., all rights reserved
    
    Permission to use, copy, modify, and distribute this software for any purpose
    with or without fee is hereby granted, provided that the above copyright
    notice and this permission notice appear in all copies, and none of the
    names : I-SYST or its contributors may be used to endorse or
    promote products derived from this software without specific prior written
    permission.
    
    For info or contributing contact : hnhoan at i-syst dot com
    
    THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
    EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
    DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
    THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    
    ----------------------------------------------------------------------------*/
    #include <stdio.h>
    #include <atomic>
    #include <inttypes.h>
    #include <cmath>
    
    #include "nrf.h"
    #include "coredev/iopincfg.h"
    #include "coredev/i2c.h"
    #include "coredev/uart.h"
    #include "iopinctrl.h"
    #include "timer_nrfx.h"
    #include "sensors/agm_mpu9250.h"
    #include "imu/imu_mpu9250.h"
    #include "stddev.h"
    #include "idelay.h"
    
    
    #define MPU9250
    #include "board.h"
    
    std::atomic<bool> g_bTest(false);
    
    void TimerHandler(Timer *pTimer, uint32_t Evt);
    
    const static TIMER_CFG s_TimerCfg = {
        .DevNo = 0,
    	.ClkSrc = TIMER_CLKSRC_DEFAULT,
    	.Freq = 0,			// 0 => Default highest frequency
    	.IntPrio = 1,
    	.EvtHandler = TimerHandler,
    };
    
    TimerLFnRFx g_Timer;
    
    
    //********** I2C **********
    static const I2CCFG s_I2cCfg = {
    	0,			// I2C device number
    	{
    		{I2C0_SDA_PORT, I2C0_SDA_PIN, I2C0_SDA_PINOP, IOPINDIR_BI, IOPINRES_PULLUP, IOPINTYPE_OPENDRAIN},
    		{I2C0_SCL_PORT, I2C0_SCL_PIN, I2C0_SCL_PINOP, IOPINDIR_OUTPUT, IOPINRES_PULLUP, IOPINTYPE_OPENDRAIN},
    	},
    	100000,	    // Rate
    	I2CMODE_MASTER,
    	5,			// Retry
    	0,			// Number of slave addresses
    	{0,},		// Slave addresses
    	true,	    // DMA
    	false,		// Use interrupt
    	6,			// Interrupt prio
    	NULL		// Event callback
    };
    
    I2C g_I2c;
    
    DeviceIntrf *g_pIntrf = &g_I2c;
    
    
    
    
    static const ACCELSENSOR_CFG s_AccelCfg = {
    	.DevAddr = MPU9250_I2C_DEV_ADDR0,
    	.OpMode = SENSOR_OPMODE_CONTINUOUS,
    	.Freq = 10000,
    	.Scale = 2,
    	.FltrFreq = 0,
    	.bInter = true,
    	.IntPol = DEVINTR_POL_LOW,
    };
    
    static const GYROSENSOR_CFG s_GyroCfg = {
    	.DevAddr = MPU9250_I2C_DEV_ADDR0,
    	.OpMode = SENSOR_OPMODE_CONTINUOUS,
    	.Freq = 50000,
    	.Sensitivity = 10,
    	.FltrFreq = 200,
    };
    
    static const MAGSENSOR_CFG s_MagCfg = {
    	.DevAddr = MPU9250_MAG_I2C_DEVADDR,
    	.OpMode = SENSOR_OPMODE_CONTINUOUS,
    	.Freq = 50000,
    	.Precision = MAGSENSOR_PRECISION_HIGH,
    };
    
    
    AgmMpu9250 g_MotSensor;
    
    AccelSensor *g_pAccel = NULL;
    GyroSensor *g_pGyro = NULL;
    MagSensor *g_pMag = NULL;
    
    uint32_t g_DT = 0;
    static uint32_t g_TPrev = 0;
    
    void TimerHandler(Timer *pTimer, uint32_t Evt)
    {
        if (Evt & TIMER_EVT_TRIGGER(0))
        {
        }
    }
    
    
    bool HardwareInit()
    {
    	bool res;
    
    	g_Timer.Init(s_TimerCfg);
    
    	res = g_I2c.Init(s_I2cCfg);
    
    	if (res == true)
    	{
    		res = g_MotSensor.Init(s_AccelCfg, &g_I2c, &g_Timer);
    		if (res == true)
    		{
    			g_pAccel = &g_MotSensor;
    		}
    
    	}
    
    	if (res == true)
    	{
    		res = g_MotSensor.Init(s_GyroCfg, &g_I2c, &g_Timer);
    		if (res == true)
    		{
    			g_pGyro = &g_MotSensor;
    		}
    	}
    
    	/*if (res == true)
    	{
    		res = g_MotSensor.Init(s_MagCfg, &g_I2c, &g_Timer);
    		if (res == true)
    		{
    			g_pMag = &g_MotSensor;
    		}
    	}*/
    
    	if (res == true)
    	{
    
    		int8_t m[9] = { 1, 0, 0,
    						0, 1, 0,
    						0, 0, 1 };
    	}
    
    	return res;
    }
    
    // Floats for storing data from IMU
    float ax=0;
    float ay=0;
    float az=0;
    float gx=0;
    float gy=0;
    float gz=0;
    float mx=0;
    float my=0;
    float mz=0;
    
    // Floats for filtering accelerometer with low-pass filter
    float thetaRAW_a;
    float phiRAW_a;
    float thetaRAW_old_a=0;
    float phiRAW_old_a=0;
    float thetaFIL_a;
    float phiFIL_a;
    
    int main()
    {
    	bool res = HardwareInit();
    
    
    	if (res == false)
    	{
    		printf("Failed initializing hardware\r\n");
    
    		return 1;
    	}
    
    	printf("MotionSensorDemo\r\n");
    
    	ACCELSENSOR_RAWDATA arawdata;
    	ACCELSENSOR_DATA accdata;
    	GYROSENSOR_RAWDATA grawdata;
    	GYROSENSOR_DATA gyrodata;
    	MAGSENSOR_RAWDATA mrawdata;
    
    	memset(&arawdata, 0, sizeof(ACCELSENSOR_RAWDATA));
    	memset(&accdata, 0, sizeof(ACCELSENSOR_DATA));
    	memset(&gyrodata, 0, sizeof(GYROSENSOR_DATA));
    
    
    	uint32_t prevt = 0;
    	int cnt = 100;
    	while (1)
    	{
    		uint32_t t = g_Timer.uSecond();
    
    
    		g_MotSensor.UpdateData();
    
    		uint32_t dt = arawdata.Timestamp - prevt;
    		prevt = arawdata.Timestamp;
    
    		g_MotSensor.Read(arawdata);
    		g_MotSensor.Read(accdata);
    		g_MotSensor.Read(grawdata);
    		g_MotSensor.Read(gyrodata);
    
    		ax=accdata.X*9.8;
    		ay=accdata.Y*9.8;
    		az=accdata.Z*9.8;
    		gx=gyrodata.X;
    		gy=gyrodata.Y;
    		gz=gyrodata.Z;
    
    		thetaRAW_a=atan2((ax/9.8)/(az/9.8),1)/2/3.141592654*360;
    		phiRAW_a=-atan2((ay/9.8)/(az/9.8),1)/2/3.141592654*360;
    
    		thetaFIL_a=.95*thetaRAW_old_a+.05*thetaRAW_a;
    		phiFIL_a=.95*phiRAW_old_a+.05*phiRAW_a;
    
    		phiRAW_old_a=phiFIL_a;
    		thetaRAW_old_a=thetaFIL_a;
    
    
    		if (cnt-- < 0)
    			{
    					cnt = 100;
    					printf(" %f %f %f \n", gx, gy, gz);
    			}
    	}
    
    
    
    
    }
    

  • Init seems fine.  I don't have the MPU on i2c interface.  I don't know what is going onbut I do know that it works in SPI.  There must be some setting or a different way to read.  Do you get the mag chip ID ?

  • Yes I changed in mag config the adress for

    MPU9250_MAG_I2C_DEVADDR

    which is declared as 0x0C

    Also I don't know whether I'm getting right values from gyroscope.

    Raw values is this:


    when the mpu is flat and I'm not moving I think I should be getting something around zero?

    also that results in that from converted data I am getting:

    Maybe it is the sensitivity problem? But I don't know actually how to set it right?

Reply Children
No Data
Related