printing a float

Thread Starter

taarabt

Joined Dec 24, 2015
6
I'm trying to print a float however when i try to use printf(%f, x) i get this error when trying to sent it to pic:
avrdude.exe: 34792 bytes of flash verified

avrdude.exe: safemode: lfuse reads as 0
avrdude.exe: safemode: hfuse reads as 0
avrdude.exe: safemode: efuse reads as 0
avrdude.exe: safemode: Fuses OK
avrdude.exe: stk500v2_recv():checksum error
avrdude.exe: stk500_2_ReceiveMessage(): timeout
avrdude.exe: stk500_2_ReceiveMessage(): timeout

if i just print a string like printf("hello") in th exact same line it works with no problems
avrdude.exe: 30328 bytes of flash verified

avrdude.exe: safemode: lfuse reads as 0
avrdude.exe: safemode: hfuse reads as 0
avrdude.exe: safemode: efuse reads as 0
avrdude.exe: safemode: Fuses OK

avrdude.exe done. Thank you.

any ideas what is going on ?
 

spinnaker

Joined Oct 29, 2009
7,830
You learned completely wrong or simply was not paying attention. My guess the later.

The pic32mx320F128H is a chip made by Microchip.

AVRDude is an utility to download/upload/manipulate the ROM and EEPROM contents of AVR microcontrollers made by Amtel.

http://www.nongnu.org/avrd
 

spinnaker

Joined Oct 29, 2009
7,830
You guessed wrong then. I would message you my Box file if i could, only to prove my point.
OK then keep trying to program a Pic with an Amtel application then. See how far it gets you. Nothing I can find anywhere says this can be done.

And you can attach files in this thread.
 

Thread Starter

taarabt

Joined Dec 24, 2015
6
I'm programing a chipkit board with MPLAB thats probably why it is possible to use avrdude, sorry, just taking my first steps here.
 

spinnaker

Joined Oct 29, 2009
7,830
I have never heard of using avrdude. There is no reason to use it. MPLab has its own ability to program a pic.

What compiler are you using? And you still have not posted the line that causes an issue.

What programmer are you using?
 

nerdegutta

Joined Dec 15, 2009
2,684
Hi.

Normally:

To program an Arduino, use the Arduino IDE
To program an ATMEL AVR, use ATMEL Studio. I believe the latest version is close to 7. And an AVR MK II.

To program a PIC, use MPLAB X, and the PCKit3 or likewise programmer. Do not try to make a programmer yourself. Not in a few years.
You can also use MikroC.

It would benefit everybody, if you inserted your source code, in code-tags, and told us which IDE you are using.
 

MMcLaren

Joined Feb 14, 2010
861
You guys should really take a quick look at the Digilent Chipkit products featuring PIC32MX while using an Arduino style bootloader and IDE.
 
Last edited:

spinnaker

Joined Oct 29, 2009
7,830
You guys should really take a quick look at the Digilent Chipkit products featuring PIC32MX while using an Arduino style bootloader and IDE.
It would have been real nice for the OP to provide us with that little bit of information that it was an Arduino that is acting as a programmer. I don't recall hearing that was possible though I see no reason why it could not be done. Which nerdgutta's statement still rings true in some respect. "Do not try to make a programmer yourself. Not in a few years.". Basically the OP is using a homemade programmer or rather a 3rd party programmer. Really bad idea in my opinion. Way too many weird problems.

Since the OP provided no information whatsoever to fix the problem. I am going to take a guess that he/she is using C32 to compile the code, based on issues with %f in the sprintf call. C18 does not support the %f format specifier so I would assume c32 does not either. To print a float do something like this:


float fBatteryVolts = 12.2;

sprintf(string,(const far rom char*)"Battery %2d.%02dV ",(int)fBatteryVolts ,(int)((fBatteryVolts - (int)fBatteryVolts) *100));
 
Last edited:
Top