Hi Sterretjie,
Thank you for your email. I changed 0000 0000 0000 0000 0000 0000 0000 0011 in the loop () and nothing changed on the Due! and nothing changed. The same LED was still flashing! I realise that my knowledge is almost zero on this chip and I managed to find the datasheet. Did not have enough time to study it carefully yet. So like some guys say RTFM, I can see there are not much available in sample format to at least read a port with 1 instruction, so let me get into the manual!!!!!!
Hi Railroader,
I am still basically where I started knowledge wise after spending a few hours on port reading and writing and managed to get a whole port working and 1 pin, but could not make enough sense to make progress. So today I am going to try your shift example out.
Regards
Cobus
Yes, that's my idea. 0 - 31....
If You want You can drop the intermediate variables and compact it to
sum = digitalRead(pin0) + (digitalRead(pin1) << 1) +.......
This ought to be rather quick. I don't know how to perform a port read of all 5 bits at the same time. However this code should work for any controller.
Hi Guys,
I managed to get the one write and change 4 ouputs done like this. Thank you for your patience with me. Reading a port with only 5 inputs of the 32 without having to gnd all the others is still a challenge.
void setup()
{
//PC0 is the erase pin
pinMode(33, OUTPUT);
pinMode(34, OUTPUT);
pinMode(35, OUTPUT);
pinMode(36, OUTPUT);
REG_PIOC_OWER = B11110;// 4 lasb bits enabled and last one not because PC0 is erase pin.
REG_PIOC_OWDR = 0XFFFFFFE0; //The lsb 6 bits = 0`s and the first 26 bits = 1`s ie disabled
}
void loop()
{
REG_PIOC_ODSR = B10000; //0x00000036/35/34/33/;
delay(100);
REG_PIOC_ODSR = 0x00000000;
delay(1000);
REG_PIOC_ODSR = B01000; //0x00000036/35/34/33/;
delay(100);
REG_PIOC_ODSR = 0x00000000;
delay(100);
REG_PIOC_ODSR = B00100; //0x00000036/35/34/33/;
delay(100);
REG_PIOC_ODSR = 0x00000000;
delay(100);
REG_PIOC_ODSR = B00010; //0x00000036/35/34/33/;
delay(1000);
REG_PIOC_ODSR = 0x00000000;
delay(1000);
}