Zero Cross Detection PIC18LF26K83

Thread Starter

SoaringFree

Joined Sep 15, 2016
20
I have recently started using the PIC18LF26K83 as it has many peripherals that I intend to use in the near future. Currently, I am working to get the Zero Cross Detection peripheral up and running and have been struggling to do so.
I have built a circuit on a breadboard to test this peripheral as follows. I am running a 5VPP sine wave from my oscilloscope into a 1MEG variable resistor set at 33k3 Ohms (RSERIES) which goes into the PIC18LF26K83 at the RB0 Pin. I have another 1MEG variable resistor used as a pull up resistor that is set at 113k2 ohms and is connected to RB0. I am using VCPINV = .75, and VPULLUP = 3v3 in my RPULLUP formula from the datasheet.
I have my ANSELB for RB0 set for analog input as well as my TRISB set for input. In looking over the data sheet, I see that I do not have to set the ZCD peripheral to pin RB0 as it states that this only applies to digital, and we are using analog for the ZCD. I find this odd as it shows the following peripherals (Page 6 of the datasheet) also on the RB0 pin: C2IN1+, CCP4, CWG1, IOCB0, and INT0. I also checked this and it does not list the ZCD in the PPS section of the datasheet. When I probe the RBO pin I am seeing the sine wave and I am also seeing .75 volts here as well. I am signaling the output state w/ an LED as can be seen in my provided code.

From looking over the datasheet and double checking everything numerous times I am now at the "head scratcher" stage and don"t know where to go in trying to get this peripheral up and running. I thought it positive to have another set of eyes take a look at where I am at with this, and to get me pointed in the right direction.
Please find attached a copy of my code as it sits now.

Thank you for all your help.

SoaringFree
 

Attachments

cmartinez

Joined Jan 17, 2007
8,722
It would be much easier for us to understand what you're trying to do if you posted a diagram of your current setup, even if it's a simple one.
 
Top