Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Speed of DsPIC affected by variable types (char, int)

Status
Not open for further replies.

kappa_am

Full Member level 6
Joined
Jul 16, 2012
Messages
331
Helped
19
Reputation
38
Reaction score
19
Trophy points
1,298
Location
Vancouver
Activity points
3,859
Hi,
I am doing some calculations using DsPIC. Many of the variables are char type. When I convert them to int type I observe large improvement in execution time. I wonder what is the cause.

Thank you
 

dsPIC have 16 bit wide program and data bus. Any fetch for program or data fetches 16 bit data. Also, all the internal registers, ALU, MAC etc are 16 bit wide. SO, when u define int in MPLAB X, it allocates 16 bits. So, all operates ideally at max rate.

Change this to 8bit and u will need padding in data if u have sufficient ram or else compiler has to optimize and throw unnecessary byte from fetched 16 bit data and perform operation, restrict it back to 8bits. More work involved so it takes more time.

dsPIC makes more sense if u have lots of data to process in 16bit format. Usually all power supply designs, motor control designs, induction heating etc. can easily be implemented with dsPIC and 16bit or Q15 math.

If u r just going to work in char's go for 8bit MCU, unless u r doing some math intensive operation like signal processing or control system etc.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top