/* 8-bit conversion function */

For Adafruit customers who seek help with microcontrollers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
jim
 
Posts: 106
Joined: Wed Feb 20, 2008 12:15 am

/* 8-bit conversion function */

Post by jim »

my kit USBminiISP works a hundred times faster than the minipov3 for my mac to get firmware on to the attiny2313. i have been failing to use my mac to make a hex file to put on a attiny2313 via USBitnyISP.

do i need a different conversion function to deal with the likes of this:

Code: Select all

 { 0b001, 0b000, 0b000, 0b000, 0b000, 0b000, 0b000, 0b000, 0b000, 25000 },
than this one?

Code: Select all

/* 8-bit conversion function */
#define B8__(x) ((x&0x0000000FLU)?1:0) \
+((x&0x000000F0LU)?2:0) \
+((x&0x00000F00LU)?4:0) \
+((x&0x0000F000LU)?8:0) \
+((x&0x000F0000LU)?16:0) \
+((x&0x00F00000LU)?32:0) \
+((x&0x0F000000LU)?64:0) \
+((x&0xF0000000LU)?128:0)


#define B8(d) ((unsigned char)B8__(HEX__(d))) 
do i need a 3bit conversion code like to the 8bit one above?

ToddK
 
Posts: 4
Joined: Wed Jan 13, 2010 5:12 pm

Re: /* 8-bit conversion function */

Post by ToddK »

I would think that all the following are equal in the compiler's mind:

0b001
0b1
0x1
0x01
0b0001
etc

I'd have to do a bit of checking with some test program and I might have time to do that later, but the c compiler should take any of those values and translate it to the value 1 internally.

Todd

User avatar
westfw
 
Posts: 2010
Joined: Fri Apr 27, 2007 1:01 pm

Re: /* 8-bit conversion function */

Post by westfw »

avr-gcc supports 0bXXX all by itself, no need to implement hacks like "#define B101 5"...

mtbf0
 
Posts: 1645
Joined: Sat Nov 10, 2007 12:59 am

Re: /* 8-bit conversion function */

Post by mtbf0 »

might be using an older version of avr-gcc. time to upgrade?

User avatar
jim
 
Posts: 106
Joined: Wed Feb 20, 2008 12:15 am

Re: /* 8-bit conversion function */

Post by jim »

thanks all,
considering i set up OSX-AVR in early 2008, this "OSX-AVR-JAN07-PPC.dmg", is probably what i am using. There appears to be nothing more recent.

i retraced my steps when setting this up for the minipov3 two years ago and got the impression that it was just going to be a pain to use avrdude with my mac and i was willing to endure rather than buy another computer.

i have whittled my errors down from thousands to 7 by learning to find and replace ob001 with B8(00000001) a bazillion and a half times over.

the errors are line spicific but i have not learned to display the line numbers in Apple's XCode.

here is the current state of error:

Code: Select all

Compiling: ledcube.c
avr-gcc -c -I. -g -Os                    -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -DF_CPU=8000000           -Wa,-adhlns=ledcube.lst  -mmcu=attiny2313 -std=gnu99 ledcube.c -o ledcube.o
ledcube.c:350:2: unterminated argument list invoking macro "B8"
ledcube.c:105: error: `B8' undeclared here (not in a function)
ledcube.c:105: error: initializer element is not constant
ledcube.c:105: error: (near initialization for `imageTab[0].BotBackRow')
ledcube.c:105: error: syntax error at end of input
ledcube.c:104: warning: array 'imageTab' assumed to have one element
make: *** [ledcube.o] Error 1
even my cat tried to help, but she might have messed it up even more.

close but no BANNED yet

mtbf0
 
Posts: 1645
Joined: Sat Nov 10, 2007 12:59 am

Re: /* 8-bit conversion function */

Post by mtbf0 »

jim wrote:considering i set up OSX-AVR in early 2008, this "OSX-AVR-JAN07-PPC.dmg", is probably what i am using. There appears to be nothing more recent.
might be worthwhile to build it yourself. save you a repeat of this grief on the next project you undertake.

don't know why people use binary constants anyway. with hex you know which bits are set without having to count all those zeros.

User avatar
jim
 
Posts: 106
Joined: Wed Feb 20, 2008 12:15 am

Re: /* 8-bit conversion function */

Post by jim »

thanks again.

http://ladyada.net/learn/avr/setup-mac.html

two years ago i tried option 2, OSX-AVR-JAN07-PPC.dmg + XCode and it worked for what i was doing till yesterday. Lucky there is also option 1 and option 3 left to try in my attempt to make the hex file.

do i have to delete OSX-AVR and or XCode?

mtbf0
 
Posts: 1645
Joined: Sat Nov 10, 2007 12:59 am

Re: /* 8-bit conversion function */

Post by mtbf0 »

jim wrote:do i have to delete OSX-AVR and or XCode?
yes, unless you want to always be changing paths and guessing which version you're running.

i'd go with option three. it's a pain, but when you're done you'll have the latest and the greatest with nothing but the newest and shiniest bugs.

User avatar
jim
 
Posts: 106
Joined: Wed Feb 20, 2008 12:15 am

Re: /* 8-bit conversion function */

Post by jim »

haha,
thanks for being great listeners
only after i publicly confess some ignorance, do i seem to solve it
problem solved
thanks for all the help

Locked
Please be positive and constructive with your questions and comments.

Return to “Microcontrollers”