stimmer:
inline void digitalWriteDirect(int pin, boolean val){
if(val) g_APinDescription[pin].pPort -> PIO_SODR = g_APinDescription[pin].ulPin;
else g_APinDescription[pin].pPort -> PIO_CODR = g_APinDescription[pin].ulPin;
}
inline int digitalReadDirect(int pin){
return !!(g_APinDescription[pin].pPort -> PIO_PDSR & g_APinDescription[pin].ulPin);
}
Hi.
Ok, I've managed to put library working with your functions, Thank you!
But it's still very slow running DEMO compared to Chipkit. I know that in chipkit, the entire byte is written to port at once and in due I'm writing bit by bit, but I'm not sure that this is enough for a huge difference in run time for demo. In chipkit it takes around 24s, I'm getting with due 44s.
Is there a way to use ODSR in this functions? Can I write to ODSR bit by bit?
From datasheet, ODSR should be used for synchronous transfer. I'm thinking, maybe using ODSR i might get bet speed.
I was trying to do this without success:
//DB00 on PIN37 -> PIO_PC5
REG_PIOC_ODSR=((VL&0x01)<<5) & 0x20;
//DB01 on PIN36 -> PIO_PC4
REG_PIOC_ODSR=(VL<<3) & 0x10;
//DB02 on PIN35 -> PIO_PC3
REG_PIOC_ODSR=(VL<<1) & 0x08;
//DB03 on PIN34 -> PIO_PC2
REG_PIOC_ODSR=(VL>>1) & 0x04;
//DB04 on PIN33 -> PIO_PC1
REG_PIOC_ODSR=(VL>>3) & 0x02;
//DB05 on PIN32 -> PIO_PD10
REG_PIOD_ODSR=(VL<<5) & 0x400;
//DB06 on PIN31 -> PIO_PA7
REG_PIOA_ODSR=(VL<<1) & 0x80;
//DB07 on PIN30 -> PIO_PD9
REG_PIOD_ODSR=(VL<<2) & 0x200;
//DB08 on PIN22 -> PIO_PB26
REG_PIOB_ODSR=(VH<<26) & 0x4000000;
//DB09 on PIN23 -> PIO_PA14
REG_PIOA_ODSR=(VH<<13) & 0x4000;
//DB10 on PIN24 -> PIO_PA15
REG_PIOA_ODSR=(VH<<13) & 0x8000;
//DB11 on PIN25 -> PIO_PD0
REG_PIOD_ODSR=(VH>>3) & 0x01;
//DB12 on PIN26 -> PIO_PD1
REG_PIOD_ODSR=(VH>>3) & 0x02;
//DB13 on PIN27 -> PIO_PD2
REG_PIOD_ODSR=(VH>>3) & 0x04;
//DB14 on PIN28 -> PIO_PD3
REG_PIOD_ODSR=(VH>>3) & 0x08;
//DB15 on PIN29 -> PIO_PD6
REG_PIOD_ODSR=(VH>>1) & 0x40;
The working code is:
//DB00 on PIN37 -> PIO_PC5
digitalWriteDirect(37,(VL & 0x01));
//DB01 on PIN36 -> PIO_PC4
digitalWriteDirect(36,(VL & 0x02));
//DB02 on PIN35 -> PIO_PC3
digitalWriteDirect(35,(VL & 0x04));
//DB03 on PIN34 -> PIO_PC2
digitalWriteDirect(34,(VL & 0x08));
//DB04 on PIN33 -> PIO_PC1
digitalWriteDirect(33,(VL & 0x10));
//DB05 on PIN32 -> PIO_PD10
digitalWriteDirect(32,(VL & 0x20));
//DB06 on PIN31 -> PIO_PA7
digitalWriteDirect(31,(VL & 0x40));
//DB07 on PIN30 -> PIO_PD9
digitalWriteDirect(30,(VL & 0x80));
//DB08 on PIN22 -> PIO_PB26
digitalWriteDirect(22,(VH & 0x01));
//DB09 on PIN23 -> PIO_PA14
digitalWriteDirect(23,(VH & 0x02));
//DB10 on PIN24 -> PIO_PA15
digitalWriteDirect(24,(VH & 0x04));
//DB11 on PIN25 -> PIO_PD0
digitalWriteDirect(25,(VH & 0x08));
//DB12 on PIN26 -> PIO_PD1
digitalWriteDirect(26,(VH & 0x10));
//DB13 on PIN27 -> PIO_PD2
digitalWriteDirect(27,(VH & 0x20));
//DB14 on PIN28 -> PIO_PD3
digitalWriteDirect(28,(VH & 0x40));
//DB15 on PIN29 -> PIO_PD6
digitalWriteDirect(29,(VH & 0x80));