0

I am using PICKIT 4, PIC16F18446 microcontroller, and MPLAB X IDE. I am following an instruction provided from Microchip, Measuring frequency

Update:

I am not entirely sure what i needs to change but I am consistently getting an output of Frequency: 25536 whether there is an input signal or not. (Image of the output, and pin configuration shown below)

enter image description here

enter image description here

enter image description here

Sam Shurp
  • 57
  • 1
  • 5
  • Is `main()` your entire code? All you do is enable global interrupts and peripheral interrupts and then go into an infinite loop. In order for something to happen, you have to define an interrupt handler for a specific interrupt (pin, etc..) and then for example the interrupt will fire when that pin value goes high or low (however you define the response). Just enabling the global and peripheral interrupts enables the checking and response to interrupts but doesn't set up any one specific interrupt. Those are just preliminary steps. – David C. Rankin Nov 01 '22 at 03:09
  • What means. "not getting anything out"? – Mike Nov 01 '22 at 06:01
  • You can't get anything out OF WHAT? AFAIS you don't configure any pin as output so you don't expect an output from chip. The only thing left is the MPLABX IDE output. Do you mean when you generate MCC code you don't see any output? Please kindly clarify your issue. – Kozmotronik Nov 01 '22 at 19:01

1 Answers1

0

The Original Poster is using a PIC18 tutorial for a PIC16F target.

The MPLABX Code Configurator (MCC) tool is an awful thing for anyone new to the Microchip development tools to use.

An MPLABX project that does what I think this tutorial is about for the PIC16F18446 target is here in my git hub repository.

MCC was used to create most of this code so you should be able to see how it was done.

This code runs in the MPLABX simulator but that is a buggy hot mess. Use it with caution.

Dan1138
  • 1,150
  • 8
  • 11
  • I am kind of happy that there is something like MCC. Seeing code generate and learning from it is really helpful. I intentionally used PIC16 instead of PIC18, and I made sure to choose RB4 of PIC16 as its has a timer (TIG). I am trying to measure frequency. Your code seems similar to the code generate by MCC which helps a lot in understanding. – Sam Shurp Nov 01 '22 at 18:18
  • @SamShurp I have updated my repository to do exactly what the PIC18F tutorial talks about with regard to using the TIMER1 gate input to measure the cycle time of the input then report that frequency in Hz. – Dan1138 Nov 01 '22 at 21:39
  • I have been trying to understand what's going by looking at your code, and MCC generated code. I have updated the post. I appreciate your help with this. – Sam Shurp Nov 06 '22 at 06:03
  • Thank you for helping me out; it finally works. – Sam Shurp Nov 07 '22 at 06:28