The main ( pressing ) issue is the interrupt..... You cant set the ADC to start conversion on the index input AND use the same interrupt to read the ADC.... It'll never be ready... When it boots it takes sooooooo long to restart the ADC conversion.... If the ADC is on continuous why don't you use the ADIF to interrupt??
One other thing!!! You are using AVDD and AVSS for the ADC reference but you haven't connected them... The warning is telling you that Vref+ is at 0v..
The main ( pressing ) issue is the interrupt..... You cant set the ADC to start conversion on the index input AND use the same interrupt to read the ADC.... It'll never be ready... When it boots it takes sooooooo long to restart the ADC conversion.... If the ADC is on continuous why don't you use the ADIF to interrupt??
If I put 'xx1xx' on ADCON3<4:0> it says: "Input Capture 1 (IC1) starts A/D sequence". The datasheet specifies that in this case the GODONE bit will be set and cleared by hardware. So doesn't that mean that I don't need an AD interrupt and that input capture 1 interrupt will do all the work?
One other thing!!! You are using AVDD and AVSS for the ADC reference but you haven't connected them... The warning is telling you that Vref+ is at 0v..
I set ADCON1 <7:6> to 00: That says: "VREF+ = AVDD, VREF- = AVSS, (AN2 and AN3 are Analog inputs or Digital I/O)". Doesn't that mean I will have +5V and 0V as reference?(VSS and VDD of the PIC which are not showed in proteus for simplicity)?
No! That chip requires the AVDD and AVSS to be connected... There are two pins 6 & 7 for the ADC only, this chip hasn't an internal Vdd and Vss for the ADC..
The motor starts but accelerates and decelerates very slow. It does respect the position of the pot(meaning it's speed varies with the it's position) but the speed modifies very very slow even if the duty cycle is 100% and even if from 100% I drop it down to 0% it decelerates very very slow
*Even if I manually set the dch and dcl to 0 in the code the motor still runs slow and yet modifies it's speed along with the pot's location...that is beyond me.
If you do that the duty cycle will have no influence on the PWM modules and the motor will run at full speed. It's basically what we did first to check if the module was configured correctly.
Are you using the ADC interrupt feauture? Because if so it must be specified in the ADCON3 that triggers are disabled(if you haven't already done that that is)
Right!!! If I set dch to 255 the motor spins very fast.... The PDCx pairs require a 14 bit number .. If we set dch to 00111111b then problems... If I set dch to 11111111b then the motor spins... This is because the PDCx value is bigger and the PWM is set to permanent 1.... I think that the PDCx pairs are out of sequence...
Right!!! If I set dch to 255 the motor spins very fast.... The PDCx pairs require a 14 bit number .. If we set dch to 00111111b then problems... If I set dch to 11111111b then the motor spins... This is because the PDCx value is bigger and the PWM is set to permanent 1.... I think that the PDCx pairs are out of sequence...
Did you get it to spin respecting the pot position?
Also the datasheets specifies:
"The upper 12 bits of PDCn hold the actual duty cycle value from PTMRH/L<11:0>, while the lower 2 bits control which internal Q-clock the duty cycle match occurs.". I didn't completely understand what these two bits actually do(to my understanding they allow for a finer resolution of the PWM signal) but the way I set it up they will always stay on 00(for which: "duty cycle match occurs on Q1").