Go Down

Topic: Compile problem using macro (Read 5061 times) previous topic - next topic


Sep 30, 2012, 10:46 pm Last Edit: Sep 30, 2012, 10:53 pm by april Reason: 1

I was just under the naive impression that the DDRB ("B" port or any other register port) was limited to declaring IO direction.

You set two registers at 255=11111111 Passing  PORTB=0 turns them all off =00000000
From Mellis
Quote from: Mellis MIT
DDRB is the data direction register for port B. It determines whether each pin is an input or an output.
   PORTB is the data register for port B. For output pins, this determines whether the pin is set high or low.

Each of the eight bits of the register corresponds to one of the eight pins of the port. The 0'th (right-most) bit of the register corresponds to PB0. The 7'th (left-most) bit to PB7. If a bit of the DDRB register is set to 1, the corresponding pin is set as an output. If the bit is 0, the pin is an input. The pins default to being inputs (i.e. the bits of DDRB default to 0). If a bit of the PORTB register is set to 1, and the pin is set as an output, the microcontroller will hold the pin high - that is, set it to 5V (or whatever voltage is used to power the microcontroller). If a bit of PORTB is 0, and the pin is an output, the microcontroller will hold the pin low (0V).


Quote from: SurferTim
As I remember, the exact file in that directory will depend on the device selected for compile.

Thanks ,I looked at 328p as an example and I found some fuse setting but not macros
Code: [Select]
/* Fuses */

/* Low Fuse Byte */
#define FUSE_CKSEL0 (unsigned char)~_BV(0)  /* Select Clock Source */
#define FUSE_CKSEL1 (unsigned char)~_BV(1)  /* Select Clock Source */
#define FUSE_CKSEL2 (unsigned char)~_BV(2)  /* Select Clock Source */
#define FUSE_CKSEL3 (unsigned char)~_BV(3)  /* Select Clock Source */
#define FUSE_SUT0   (unsigned char)~_BV(4)  /* Select start-up time */
#define FUSE_SUT1   (unsigned char)~_BV(5)  /* Select start-up time */
#define FUSE_CKOUT  (unsigned char)~_BV(6)  /* Clock output */
#define FUSE_CKDIV8 (unsigned char)~_BV(7) /* Divide clock by 8 */

/* High Fuse Byte */
#define FUSE_BODLEVEL0 (unsigned char)~_BV(0)  /* Brown-out Detector trigger level */
#define FUSE_BODLEVEL1 (unsigned char)~_BV(1)  /* Brown-out Detector trigger level */
#define FUSE_BODLEVEL2 (unsigned char)~_BV(2)  /* Brown-out Detector trigger level */
#define FUSE_EESAVE    (unsigned char)~_BV(3)  /* EEPROM memory is preserved through chip erase */
#define FUSE_WDTON     (unsigned char)~_BV(4)  /* Watchdog Timer Always On */
#define FUSE_SPIEN     (unsigned char)~_BV(5)  /* Enable Serial programming and Data Downloading */
#define FUSE_DWEN      (unsigned char)~_BV(6)  /* debugWIRE Enable */
#define FUSE_RSTDISBL  (unsigned char)~_BV(7)  /* External reset disable */


Oct 01, 2012, 04:49 am Last Edit: Oct 01, 2012, 04:55 am by SurferTim Reason: 1
Maybe I misunderstood. Exactly what macros are you looking for?
Did you look at the "io.h" file there?


Oct 01, 2012, 10:41 pm Last Edit: Oct 01, 2012, 10:53 pm by april Reason: 1
I was referring to this macro
Code: [Select]
_BV(?) whatever bit you put in here (?) is set ie _BV(3) sets bit 3 on

I did look in io.h but did not see it ?


Hmm curiouser and curioser if that's a word. I have been looking at compiling these outside of Arduino but using the same header files and compile tools.

The truth of the matter is the PB0/PORTB0  thing  it is an Arduino anomaly !
Using the same header files as used by Arduino I have compiled and flashed an Atmega328p with all of these original examples with the expected results .

The cross definitions in the headers files are correct . The problem then, is in the Arduino usage of these somewhere.
Isn't it peculiar how people seek to hide the truth to protect the established system they have an allegiance to.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131