Sunday, August 31, 2014

32 Mhz PIC

This is more about my Oscilloscope rather than the processor.  Using the new enhanced 14 bit core is really exciting for me now.  One of the things I have always had trouble with using PICs is the oscillator.  I start using crystal resonators, which are very fickle, and will have trouble starting if they don't have a matched impedance pathways to the PIC.  Then I moved on to real oscillators, but had that impedance matching problem, which imposed speed limits.  With an oscillator I could only go up to about 4 MHz.  But now, with the enhanced 14 bit core, and integrated oscillator I can go up to 32 MHz.  Big performance boost...
Part of the configuration on the PIC16F1788 allows me to port the internal oscillator to an I/O pin, and it can be used to synchronize another part to this parts clock.  Also this allows me to verify that the internal clock is running, sometimes that's a question.  What I was getting to is the oscilloscope is looking at the PICs 32 MHz clock.  That is impressive.  This is the Velleman HPS140i pocket Oscilloscope.  Lets see you do that with your phone app scope, LOL!

PIC16F1788 Interrupts

I've been working with the Enhanced 14 bit core lately, and porting my code over from an old 14 bit core (PIC16F876).  The new PIC16F1788 has a lot more peripheral functionality, which creates some difficulties when setting up the device.  On this particular project I am using the external interrupt to trigger a pulse generator.  In the code I defined my interrupt routine, set the interrupt register to fire on INTE (External interrupt), and branch to the pulse generator routine.  This is pretty simple on the regular, old 14 bit core, but with the enhanced 14 bit core there are analog options on port B, and they are set to on by default.  So I got everything setup, installed the new processor, and loaded my code, and went to test the board, no interrupts.  I got stuck there for some time because I didn't know about the analog select register, which disconnects the INTE interrupt signal from the external pin, and turns the port into an analog input.  The ANSEL (Analog Select Registers) are set by default, and you have to clear these bits to use the port as a digital I/O pin.
The boards I build are usually hand assembled on a piece of Vectorboard, and wired point to point.  There are noise issues because there is no ground plane in the Vectorboard.  This has been a problem in the past because I was limited to running my boards at 4 MHz.  This is the reason I moved to the Enhanced 14 bit core.  The PIC16F1788 has an internal oscillator that can run up to 32 MHz, making my pulse generator a lot faster, and solving a big problem...
This particular project required a dual core board.  Each processor has a specific task, which cannot be interrupted by another process.  One is a frequency converter running a tachometer, and the other is a PWM generator used for brushless DC motor control.  Switching from the old 14 bit core to the enhanced 14 bit core allowed me to get the high speed clock to meet the timing requirements for the project.  Now I am in the process of learning to use the PSMC (Programmable Switch Mode Controller) which can do high performance PWM, and other high performance pulse schemes used to run brushless DC motors.