Re: [avr-gcc-list] Using PORTB with variables, PORTB = var
[EMAIL PROTECTED] wrote: This doesn't work as expected... not sure why. I would like to keep the functions if possible, I'm thinking it has something to do with scope perhaps? I am new to C by the way, if it isn't evident already (: It has nothing to do with scope. It has more to do with your being new to C (and previously programming in assembler?) if I understand properly what you are trying to do based on your code examples. Originally you stated that you weren't getting the behaviour you expected but never stated what you did expect. Your code examples lead me to think you have 8 LED's connected to port B of an AVR. You want to turn the first LED on then off, followed by the second, the third, etc. After the eighth one, you want to start at the first one again. Assuming that is what you want to do, you are almost there. The first issue with your code is that var is a 16-bit value which you are outputting to an 8-bit port. var should be declared as an 8-bit value. The second issue is with your use of the C operator . This is equivalent to a shift operation in assembly language. It is NOT the same as a rotate operation you may have used in assembly language. The in C is more like a simple arithmetic(?) shift you find in some microcontrollers. The bits shift left until they reach the MSB then they fall off the MSB after that. A rotate instruction that you find in some microcontrollers will take the value in the MSB and place it in the LSB while shifting all other bits left. A simple fix to the program is to declare var as an 8-bit value. Then, in the change() function, add an if statement after the bit shift if (var == 0) var = 1; It won't be the most elegant way of doing things but it should give you the effect you want. -- Cheers! Kevin. http://www.interlog.com/~kcozens/ |What are we going to do today, Borg? Owner of Elecraft K2 #2172|Same thing we always do, Pinkutus: | Try to assimilate the world! #include disclaimer/favourite | -Pinkutus the Borg ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] avr libc configure error
Dave wrote: I am not sure if this is the right place to post this question, but I am having trouble with configuring avr libc. I would like to use avr-gcc, and avr libc is the only source file I could find. My system is Mac OS X 10.3.9, and gcc 3.3. I get the following output: [snip] checking for gcc option to accept ANSI C... none needed checking for style of include used by make... GNU checking dependency style of gcc... gcc3 checking for avr-as... no checking for as... as checking for avr-ranlib... no checking for ranlib... ranlib checking for avr-ar... no checking for ar... ar configure: error: Wrong C compiler found; check the PATH! I'm in a similar situation except in my case I'm trying to set up a tool chain for Linux. From what I know, you need to build and install binutils for AVR first and then the compiler. Once those are in place you can build avr-libc. The output from ./configure which you included in your message indicates you don't have the binutils package installed. Your comments indicate you are also missing the compiler which you indicate when you stated you couldn't find a source file for avr-gcc. From what I have learned, AVR support is available in the official sources of binutils and gcc. Grab the official sources and specify --target=avr when you run the configure stage for these two packages. At least, that is what I have done so far. After you have binutils and gcc packages for avr installed you may or may not have the same problem I ran in to where avr-libc fails during the configure step. In my case it seems to run some a test involving compilation which fails due to its claim about missing support for the avr2 architecture. -- Cheers! Kevin. http://www.interlog.com/~kcozens/ |What are we going to do today, Borg? Owner of Elecraft K2 #2172|Same thing we always do, Pinkutus: | Try to assimilate the world! #include disclaimer/favourite | -Pinkutus the Borg ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list