Greeting all, I'm trying to write a simulate function to generate triangle wave form to test on Keil IDE, but I could not make it. I've read the code examples in Simulation section for sine, square and saw tooth, but could not figure out how to write triangle function. Can some one spend some time to help me to go through this. I'm novice in C, so please bear with me. Any inputs will be greatly appreciated. Have a great day. PS: With this function I can generate saw tooth wave form but I can't change or set frequency.
signal void Adc_0 () { float volts; float limit; limit = 5.0; while (1) /* forever */ { volts = 0; while (volts < limit) { ain0 = volts; /* analog input-0 */ swatch (0.0002); /* 200us */ volts += 0.1; /* increase voltage */ } volts = limit; while (volts > 0.0) { ain0 = volts; swatch (0.0002); /* 200us */ volts -= 0.1; /* decrease voltage */ } } }