Hi,
I'm not writing code.
But you will find people to help you to write your own code.
SCR control.
How is your SCR gate control hardware?
Isolating, or not? If isolating: how? Transformer, optical...?
Do you need pulse trains?
One or two SCRs?
What is the load? Purely resistive, capacitive, inductive.
(In worst case a transformer, which is very critical on trigger unsymmetries, causing DC voltage)
What frequency?
What smallest delay, what biggest delay?
Do you want to build a true regulation, or just a angle control?
Where does your setpoint come from?
In either case.
* you need to detect zero cross. In both directions.
* then you need to start a trigger delay
* generate the firing signal
* switch off the firing signal
* wait for the next zero cross.
Because it is a timing critical application ..i'd use hardware periferal. Capture, (PWM) signal generation, timer/counter, ISR.
This all depends on your used hardware. Therefore you should give us the informatiins.
But I (we) don't want to work through complete datasheets, therefore you should do this.
Best is if you could give all necessary information at once, not piece by piece.
Klaus