Solved! Go to Solution.
UUUaauuuu....
Afer 10 minutes of my lat port I found my problem.
I just add the pragma:
#pragma options align=packed
and now eveything is ok...
I used this in older designs and I thought I added it in all necessary parts of my code, but it seems I forgot...
Thanks
Ricardo Raupp
Ooooops..sorry
Hi..
Have you solved your issue?
I strongly use pure virtual functions in order to build components x drivers, so that to keep a comon interface for the components I create.
I uses this feature very well ib S08 mcus (CW6.2).
It works perfectly.
Now I´m porting this application for ColdFire (MCF52259) using CW7.1.
It is a strange.
I hace a i2c class wich is derived from I_i2c class wich has pure virtual functions (it is just a interface), wich MUST be implemented in the i2c class.
Like:
// the interface (base class)
class I_i2c
{
private:
public:
I_i2c(){};
virtual void init(uint32 baud)=0;
virtual uint8 read(uint8 *p_out,uint8 size,uint8 device_address,const uint8 *p_reg_address,uint8 address_size)=0;
virtual uint8 write(uint8 *p_in,uint8 size,uint8 device_address,const uint8 *p_reg_address,uint8 address_size)=0;
};
and the class to instantiate objects with I_i2c interface
class I2c : public I_i2c
{
private:
uint32 real_baud;
void delay_10us(void);
void delay_125us(void);
void send_stop(void);
void busy_loop(void);
uint8 write_busy_loop(uint8 data);
public:
I2c();
// base class virtual functions
void init(uint32 baud);
uint8 read(uint8 *p_out,uint8 size,uint8 device_address,const uint8 *p_reg_address,uint8 reg_address_size);
uint8 write(uint8 *p_in,uint8 size,uint8 device_address,const uint8 *p_reg_address,uint8 reg_address_size);
};
In the main file I create a object i2c:
I2c i2c0;
when I call:
i2c0.init, it works perfectly.
But, I usually access this objects by a pointer for its base class (interface)., like
I_i2c *p=&i2c0;// poits to the base class - interface
I cam call init by:
p->init();
Works fine too...
My problem is ...
I made the same thing for the class Uart (component) and I_uart (interface).
For my surprise for this class, I do through assembly lines when accessing it via pointer, like
Uart uart_0;//derived from I_uart
I_uart *p=&uart0;
p->init() /// CRASH here...!!!
Summarizing:
1- both objects ( i2c and uart_0 ) were working fine ( can be accessed by pointers) in CW6.2
2- Only i2c object is working now
3- The uart_0 object/class has the SAME approch of i2c object/class, I mean: declaration / definition etc...
I appreciate your help..it´s not easy to share virtual functions kwnowledgment...
Thanks
Ricardo Raupp
UUUaauuuu....
Afer 10 minutes of my lat port I found my problem.
I just add the pragma:
#pragma options align=packed
and now eveything is ok...
I used this in older designs and I thought I added it in all necessary parts of my code, but it seems I forgot...
Thanks
Ricardo Raupp
Hi g