Hi cmaglie.
Yes, it has been tested that way also, in fact, that is the original code.
stimmer:
P_LED = portOutputRegister(digitalPinToPort(13));
This line reads the current value of the port output register and stores it in P_LED. This is almost certainly not what you wanted to do.
Stimmer, I think I understand what you mean.
What we are trying to do is to get the port address.
This code in mega works this way:
#define sbi(reg, mask) *reg |= mask
#define cbi(reg, mask) *reg &= ~mask
volatile uint8_t * P_LED;
uint16_t B_LED;
void(loop)
{
P_LED = portOutputRegister(digitalPinToPort(13));
B_LED = digitalPinToBitMask(13);
sbi(P_LED,B_LED);
cbi(P_LED,B_LED);
}
But when we ported this code to Due like this:
#define sbi(reg, mask) *reg |= mask
#define cbi(reg, mask) *reg &= ~mask
volatile uint32_t * P_LED;
uint32_t B_LED;
void(loop)
{
P_LED = portOutputRegister(digitalPinToPort(13));
B_LED = digitalPinToBitMask(13);
sbi(P_LED,B_LED);
cbi(P_LED,B_LED);
}
It doens't compile complaining that RwREG is not compatible with volatile uint32_t*.
Can you give us a clue why?
I confess, i'm very bad with pointers...