I have been struggling and tried everything possible to understand but no use, and i really need help here, I have created a sine look up table every 5 degree (i will modify to create a 1024-point sine look up table once i am clear with this). The array is like below, i have not added all the values, there will be some negative values as well.
I want to generate a sine wave using PWM signal duty cycle variation. Some of the understandings i have are
a. Make the sinearray negative values to positive values.
b. I can generate pwm frequency of ex: 10KHz and in the update interrupt i can update the duty cycle register.
Now the task is for example i have to generate 1KHz , 2KHz sine wave, what i have to do?
c. I am running the main clock at say 4MHz (after pre scaler) then for 10KHz the ARR register is 4MHz / 10KHz = 400 count.
How do i load the sinevalues into duty cycle register?
Code:
sinearray[]={0.087155743 0.173648178 0.258819045 0.342020143 0.422618262 0.5 0.573576436 0.64278761 0.707106781 0.766044443 0.819152044 0.866025404 0.906307787, -0.087155743, -0.173648178, -0.258819045, -0.342020143, -0.422618262, -0.5}
a. Make the sinearray negative values to positive values.
b. I can generate pwm frequency of ex: 10KHz and in the update interrupt i can update the duty cycle register.
Now the task is for example i have to generate 1KHz , 2KHz sine wave, what i have to do?
c. I am running the main clock at say 4MHz (after pre scaler) then for 10KHz the ARR register is 4MHz / 10KHz = 400 count.
How do i load the sinevalues into duty cycle register?
