2008 02 Feb

I have just acquire this PIC 16F690 due to lack of hardware support from my old PIC 16F628a. Didn’t have I2C Slave by hardware and only 1 PWM (pulse width modulation) module available! I2C Slave by hardware was already tested on my previous post!

I have tested the PWM on this new PIC and found the results to be beyond my expectations! It is also configured with 1 PWM module but with a special capability! This signal will be available in pin RC5/CCP1/P1A and can be multiplexed to 3 other outputs, RC4/C2OUT/P1B, RC3/AN7/P1C and RC2/AN6/P1D. For P1A output the PWM signal will always be present but for P1B, P1C and P1D can be set/reset at any time. In my next example I will configure a PWM pulse with frequency of 500Hz (2ms period) and Duty-Cycle to 25% available to outputs P1A and P1B. From 3 to 3 seconds will switch configuration to activate/deactivate PWM pulse on output P1B.

This will be required to drive my previous module that will control the DC motors (will need to have PWM switching between P1B and P1C - this will invert DC motor direction): http://www.botdream.com/blog/2007/11/01/2nd-h-bridge-circuit-is-now-completed/

For this test I’ve assembled the following circuit:
PWM 2Channels Continue reading »

2008 01 Feb

I have now completed my I2C Master/Slave communication test. Quite happy with the results! Before getting started I needed to refresh my memory on I2C protocol, how Master and Slave devices would communicate, how data flow between devices. Found this nice tutorial on the web: http://www.best-microcontroller-projects.com/i2c-tutorial.html

As I previously referred on other posts, the PIC 16F690 will now support I2C protocol by hardware for the slave device, meaning that Interrupt Service Routine will be available, serving I2C Master whenever necessary without the necessity to pool the I2C bus. This also will permit Slave PIC to run other tasks like acquiring data from Analog-to-Digital inputs, control outputs, read inputs, etc, and still server PIC Slave without causing any delay on I2C bus. Unfortunately I2C Master is not supported by hardware for this PIC (I2C Master mode is also supported, please check datasheet: http://ww1.microchip.com/downloads/en/DeviceDoc/41262E.pdf page 197 -> 13.13 Master Mode). Not a problem, Master PIC will receive commands from PC (Via RS232 interface - serial communication) that will be stored on buffer to be processed whenever possible!

For the test I’ve used 2 PICs 16F690 @ 4Mhz and 1 RS232 interface for debug. Master PIC will connect to Lab PC by RS232 (COM1) for debugging purpose and to Slave PIC by I2C bus.

PIC I2C Master/Slave communication

Continue reading »