I already tried this with the minimum reload in Ra and 50% Duty-Cycle. But it still isn't faster than 700 KHz. I guess it is because of the inner routine which takes too long.
As well when trying the ISR I have the problem with the duty cycles entering and exiting the ISR so this slows it down as well and I don't get any faster.
Also I can't just toggle my Data becasue 1 Data Package is in a range of 12-bit so I need to shift it out plus I dont need onyl the one Data pin but some more pins where I can set/clear registers and another Data Pin where I can select the line I am in.
So imo Timer does not help at all when my processor does not set/clear the registers any faster than in the Code above.
I tried toggling a sole pin in loop like this:
void loop(){
while(true){
//Toggle PIN
PIOC->PIO_ODSR ^= P21;
}
}
And still only got somthing like 4Mhz so the controller does so many things nearby that it takes 21 times the processor clock frequency to toggle a sole pin !
So with this amount of code and registers I use it surely is possible that I only get a frequency of 700 KHz but what I am asking myself is where does the rest of the processor clock gets lost?
Or do you get a faster response when doing this? So maybe I just need to set some other registers?
For another option I thought about using SPI to transfer data and using a timer to toggle the pin used by the timer without an ISR being used. The other data I need to get some timing but I guess it should work with some global variables/software triggers. But it would take a new mount for the due.