Vangelis Rokas wrote:
> What differences are there? Can you send us a .diff file? and a short
> description of your changes?
I tested my functions again and on my 18f2550 board (18f2455/4455/4550
are similar) those function work
Attached to this mail you find the diff file.
I tried to encapsulate every change in an #ifdef command and made the
diff with "svn diff" (pls ignore the sim/ucsim/libtool.rej, donno why
svn adds this.)
The main diff between the pic18fXX and pic18fXXX are that those with 4
number have ADCON0-2 while those with 3 number only have ADCON0-1 to
control the ad channels. Sadly even thos with 4 numbers differ in their
way to configure the ad parts of the chip.
Is it possible to add possible to add a warning in the #else path when
using a function which is not directly programmed for the give chip?
If you have any questions regarding my code please fell free to ask them.
jan
Index: sim/ucsim/libtool
===================================================================
--- sim/ucsim/libtool (Revision 4631)
+++ sim/ucsim/libtool (Arbeitskopie)
@@ -35,7 +35,7 @@
# ### BEGIN LIBTOOL CONFIG
-# Libtool was configured on host viktoria:
+# Libtool was configured on host castor2:
# Shell to use when invoking shell scripts.
SHELL="/bin/sh"
Index: device/include/pic16/adc.h
===================================================================
--- device/include/pic16/adc.h (Revision 4631)
+++ device/include/pic16/adc.h (Arbeitskopie)
@@ -53,6 +53,22 @@
/* channel selection */
+#if defined(pic18f2455) || defined (pic18f2550) \
+ || defined(pic18f4455) || defined (pic18f4550)
+#define ADC_CHN_0 0x00
+#define ADC_CHN_1 0x01
+#define ADC_CHN_2 0x02
+#define ADC_CHN_3 0x03
+#define ADC_CHN_4 0x04
+#define ADC_CHN_5 0x05
+#define ADC_CHN_6 0x06
+#define ADC_CHN_7 0x07
+#define ADC_CHN_8 0x08
+#define ADC_CHN_9 0x09
+#define ADC_CHN_10 0x0a
+#define ADC_CHN_11 0x0b
+#define ADC_CHN_12 0x0c
+#else /* all other devices */
#define ADC_CHN_1 0x00
#define ADC_CHN_2 0x01
#define ADC_CHN_3 0x03
@@ -60,9 +76,53 @@
#define ADC_CHN_5 0x05
#define ADC_CHN_6 0x06
#define ADC_CHN_7 0x07
+#endif
/* reference and pin configuration */
+#if defined(pic18f2455) || defined (pic18f2550) \
+ || defined(pic18f4455) || defined (pic18f4550)
+#define ADC_CFG_13A_0R 0x01
+#define ADC_CFG_13A_1R 0x11
+#define ADC_CFG_13A_2R 0x31
+#define ADC_CFG_12A_0R 0x03
+#define ADC_CFG_12A_1R 0x13
+#define ADC_CFG_12A_2R 0x33
+#define ADC_CFG_11A_0R 0x04
+#define ADC_CFG_11A_1R 0x14
+#define ADC_CFG_11A_2R 0x34
+#define ADC_CFG_10A_0R 0x05
+#define ADC_CFG_10A_1R 0x15
+#define ADC_CFG_10A_2R 0x35
+#define ADC_CFG_09A_0R 0x06
+#define ADC_CFG_09A_1R 0x16
+#define ADC_CFG_09A_2R 0x36
+#define ADC_CFG_08A_0R 0x07
+#define ADC_CFG_08A_1R 0x17
+#define ADC_CFG_08A_2R 0x37
+#define ADC_CFG_07A_0R 0x08
+#define ADC_CFG_07A_1R 0x18
+#define ADC_CFG_07A_2R 0x38
+#define ADC_CFG_06A_0R 0x09
+#define ADC_CFG_06A_1R 0x19
+#define ADC_CFG_06A_2R 0x39
+#define ADC_CFG_05A_0R 0x0a
+#define ADC_CFG_05A_1R 0x1a
+#define ADC_CFG_05A_2R 0x3a
+#define ADC_CFG_04A_0R 0x0b
+#define ADC_CFG_04A_1R 0x1b
+#define ADC_CFG_04A_2R 0x3b
+#define ADC_CFG_03A_0R 0x0c
+#define ADC_CFG_03A_1R 0x1c
+#define ADC_CFG_03A_2R 0x3c
+#define ADC_CFG_02A_0R 0x0d
+#define ADC_CFG_02A_1R 0x1d
+#define ADC_CFG_02A_2R 0x3d
+#define ADC_CFG_01A_0R 0x0e
+#define ADC_CFG_01A_1R 0x1e
+#define ADC_CFG_01A_2R 0x3e
+#define ADC_CFG_00A_0R 0x0f
+#else /* all other devices */
#define ADC_CFG_8A_0R 0x00
#define ADC_CFG_7A_1R 0x01
#define ADC_CFG_5A_0R 0x02
@@ -78,8 +138,8 @@
#define ADC_CFG_2A_2R 0x0d
#define ADC_CFG_1A_0R 0x0e
#define ADC_CFG_1A_2R 0x0f
+#endif
-
/* initialize AD module */
void adc_open(unsigned char channel, unsigned char fosc, unsigned char pcfg, unsigned char config);
Index: device/lib/pic16/libio/adc/adcsetch.c
===================================================================
--- device/lib/pic16/libio/adc/adcsetch.c (Revision 4631)
+++ device/lib/pic16/libio/adc/adcsetch.c (Arbeitskopie)
@@ -35,18 +35,33 @@
void adc_setchannel(unsigned char channel) __naked
{
#if 0
+#if defined(pic18f2455) || defined (pic18f2550) \
+ || defined(pic18f4455) || defined (pic18f4550)
+ ADCON0 &= ~(0xf << 2);
+ ADCON0 |= channel << 2;
+#else /* all other devices */
ADCON0 &= ~(0x7 << 3);
ADCON0 |= channel << 3;
+#endif
#else
channel;
__asm
+#if defined(pic18f2455) || defined (pic18f2550) \
+ || defined(pic18f4455) || defined (pic18f4550)
+ movlw 0xc3
+#else /* all other devices */
movlw 0xc7
+#endif
andwf _ADCON0, f
movlw 0x01
movf _PLUSW1, w
-
+#if defined(pic18f2455) || defined (pic18f2550) \
+ || defined(pic18f4455) || defined (pic18f4550)
+
+#else /* all other devices */
rlcf _WREG, w
+#endif
rlcf _WREG, w
rlcf _WREG, w
Index: device/lib/pic16/libio/adc/adcopen.c
===================================================================
--- device/lib/pic16/libio/adc/adcopen.c (Revision 4631)
+++ device/lib/pic16/libio/adc/adcopen.c (Arbeitskopie)
@@ -45,16 +45,36 @@
ADCON1 = 0;
/* setup channel */
+#if defined(pic18f2455) || defined (pic18f2550) \
+ || defined(pic18f4455) || defined (pic18f4550)
+ ADCON0 |= (channel & 0x07) << 2;
+#else
ADCON0 |= (channel & 0x07) << 3;
+#endif
/* setup fosc */
+#if defined(pic18f2455) || defined (pic18f2550) \
+ || defined(pic18f4455) || defined (pic18f4550)
+ ADCON2 |= (fosc & 0x03);
+#else /* all other devices */
ADCON0 |= (fosc & 0x03) << 6;
ADCON1 |= (fosc & 0x04) << 4;
+#endif
/* setup reference and pins */
+#if defined(pic18f2455) || defined (pic18f2550) \
+ || defined(pic18f4455) || defined (pic18f4550)
+ ADCON1 |= pcfg & 0x3f;
+#else
ADCON1 |= pcfg & 0x0f;
-
+#endif
+
+#if defined(pic18f2455) || defined (pic18f2550) \
+ || defined(pic18f4455) || defined (pic18f4550)
+ ADCON2 |= (config & ADC_FRM_RJUST);
+#else
ADCON1 |= (config & ADC_FRM_RJUST);
+#endif
if(config & ADC_INT_ON) {
PIR1bits.ADIF = 0;
Index: device/lib/pic16/libio/adc/adcbusy.c
===================================================================
--- device/lib/pic16/libio/adc/adcbusy.c (Revision 4631)
+++ device/lib/pic16/libio/adc/adcbusy.c (Arbeitskopie)
@@ -11,7 +11,12 @@
#else
__asm
movlw 0x00
+#if defined(pic18f2455) || defined (pic18f2550) \
+ || defined(pic18f4455) || defined (pic18f4550)
+ btfsc _ADCON0bits, 0
+#else /* all other devices */
btfsc _ADCON0bits, 2
+#endif
addlw 0x01
return
__endasm;
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Sdcc-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sdcc-user