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.

Problem with debusgging atoi function in MPLAB using PICKIT3

Status
Not open for further replies.

flote21

Advanced Member level 1
Advanced Member level 1
Joined
Jan 22, 2014
Messages
411
Helped
1
Reputation
2
Reaction score
3
Trophy points
1,298
Visit site
Activity points
5,595
Hello people,

I am trying to convert an array of 2 characters into integer 16 bits usign atoi function but when I debug my program with MPLAB the int value is always 0. Is there any problem using this conversion functions?

PD; The compiler is XC8 => PIC18F4520.

Thanks!
 

post a piece of code did you pass a pointer or char directly ?

Hi thank you very much for your attention..This is the code and it does not work with the XC8 compiler.

unsigned char humidlcon_hum[2]={0x12,0x15};
unsigned int honeywell_hum;

honeywell_hum = atoi(humidlcon_hum);
 

Code:
unsigned char humidlcon_hum[2]={0x12,0x15};
unsigned int honeywell_hum;

honeywell_hum = atoi(humidlcon_hum);
The code can't work, at least for two reasons:
-the string is missing a terminating null
-0x12 and 0x15 aren't valid numeric characters

Code:
unsigned char humidlcon_hum[3]={0x32,0x35,0};
respectively
unsigned char humidlcon_hum[]= "25";
should work.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top