______________________________________________________________________ > < > MCP4X100 library v1.02 < > for < > PICos18 release 2.07 < > < > PICos18 - Real-time kernel for PIC18 family < > < > < > www.picos18.com www.pragmatec.net < >______________________________________________________________________< This file contains all necessary informations to use properly the MCP4X100 library for PICos18 v2.07. Download the last PICos18 kernel version from www.picos18.com. ______________________________________________________________________ > < > I - Zip file content < >______________________________________________________________________< The mcp4x100 zip file contains : - mcp4x100.c : to use the mcpx100, x digital potentiometer with SPI - mcp4x100.h : header file - mcp4x100.txt : this file This mcp4x100 library only needs the PICos18 SPI driver to work. So please, configure the SPI driver first. Place the C and H file in your project directory. Adapt settings properly depending of your MCP4X100 configuration (#define present at the top of the H file). This library is supposed to be use with PICos18 and has been tested with MPLAB 7.22 and C18 v3.00. Do not use this driver at a frequency lower than 8 Mhz (use the PIC18 PLL to increase the internal frequency). ______________________________________________________________________ > < > II - Hardware settings < >______________________________________________________________________< In mcp4X100.h, update the local defintions to match your hardware: /********************************************************************** * ----------------------- MCP4X100 USER SETTINGS --------------------- **********************************************************************/ // Chip select definition #define CS_PORT_MCP41100 PORTB #define CS_BIT_MCP41100 0 In this example the MCP41100 device will be connected to the PORTB0 of the PIC18. Change it if you connect your device to another port. The CS_BIT accept a value from 0 to 7. CD_PORT is a PIC18 register (PORTA, PORTB, ...). ______________________________________________________________________ > < > VI - MCP4X100 driver usage < >______________________________________________________________________< In the application task, include the driver header: #include "MCP4X100.h" See hereafter an basic example : #include "define.h" #include "MCP4X100.h" /********************************************************************** * Definition dedicated to the local functions. **********************************************************************/ #define ALARM_TSK0 0 /********************************************************************** * ------------------------------ TASK0 ------------------------------- * * First task of the tutorial. * **********************************************************************/ TASK(TASK0) { unsigned char consigne = 0; TRISEbits.TRISE0 = 0; mcp4x100_Init(); SetRelAlarm(ALARM_TSK0, 300, 300); while (1) { WaitEvent(ALARM_EVENT); ClearEvent(ALARM_EVENT); LATEbits.LATE0 = !LATEbits.LATE0; mcp4x100_SetValue(MCP4X100_POT0, consigne); consigne ++; } } ______________________________________________________________________ > < > VII - Conclusion < >______________________________________________________________________< This MCP4x100 is provided from the PICos18 web site with other drivers dedicated to other SPI peripherals. Do not hesitate to check periodicaly the www.picos18.com web site in order to download the last versions of PIC18 drivers for PICos18. /* End of File : MCP4x100.txt */