A little mistake in the ADC-modul !?

General discussion relating to the library modules supplied with the compiler

Moderators: David Barker, Jerry Messina

Post Reply
CS
Posts: 127
Joined: Thu Nov 02, 2006 9:14 am

A little mistake in the ADC-modul !?

Post by CS » Tue May 06, 2008 4:25 pm

Hi David,

I think there is a little mistake in the adc-module. When someone want to work with a PIC 18F1320 and Vref the mistake is shown.

This is the original code:

Code: Select all

Public Dim
#if _device in (18F1220, 18F1320)
   // ADCON0...
   VCFG1   As ADCON0.6,
   VCFG0   As ADCON0.5,
   CHS2    As ADCON0.4,
   CHS1    As ADCON0.3,
   CHS0    As ADCON0.2,
   GO_DONE As ADCON0.1,
   ADON    As ADCON0.0,
....
And this is how it should be:

Code: Select all

Public Dim
#if _device in (18F1220, 18F1320)
   // ADCON0...
   VCFG1   As ADCON0.7,
   VCFG0   As ADCON0.6,
   CHS2    As ADCON0.4,
   CHS1    As ADCON0.3,
   CHS0    As ADCON0.2,
   GO_DONE As ADCON0.1,
   ADON    As ADCON0.0,
...
In the Datasheed page 155 you can see that the bit 5 is not implemented.

Reguards

CS

liak
Registered User
Registered User
Posts: 195
Joined: Fri Oct 05, 2007 12:26 am

Any side effects of this?

Post by liak » Fri May 09, 2008 11:41 pm

Dear CS,
I am using PIC18F1320 for my project.
Do you have any idea what effects the so called little mistake that you have detected will produce?
I have posted just recently on the strange behaviour of my PIC 1320. Haven't really gone down to very low level yet to debug the problem.
My 1320 won't run without the MAX232 connected. When I reconnect it, even without any signal going to the PIC, it will turn alive again. I will check the pins and the data sheet again. But I would definitely like to hear from you if you think my problem is caused by the "mistake" you have detected. Thanx. :!: :!: :!:

CS
Posts: 127
Joined: Thu Nov 02, 2006 9:14 am

Post by CS » Sat May 10, 2008 1:17 am

Hi liak,

its like I pointed out. The little mistake concerns only the Voltage Referenz configuration.

If you use the USART modul to send or receive data in your program you must not disconnect the Max232 because that lets the Pic hang.

My 18F1320 runs perfect!

Let us see some code!

Reguards

CS

liak
Registered User
Registered User
Posts: 195
Joined: Fri Oct 05, 2007 12:26 am

Post by liak » Sat May 10, 2008 4:03 am

Here are my codes:

Code: Select all


Device = 18f1320
Clock = 20                             

Config MCLRE = off
Config lvp = off


Include "pwm"                           'pwm control module
Include "USART"        'universal asynchronous receive transmit module
Include "Utils"                         'swordfish utilities module
Include "MyLib"                       'own utils library for RS232


SetAllDigital

'set mode pin as input
Input(ModePin)


InitEEPROM
'must check availability of EEPROM
If Available Then
  High(Indicator)
  DelayMS(1000)
  Low (Indicator)
  DelayMS(500)
End If

DelayMS(3000)
'allow time for user to set button up on ModePin 

If ModePin = 0 Then 
    GoTo RecordMode
End If

If ModePin = 1 Then
    GoTo PlayBackMode
End If


PlayBackMode:
'While 1 = 1
    PlayBack            'sub does not use USART/RS232 function
Wend 

RecordMode:
'RS232 Record Mode
RunRS232 
End
:?: Any mistakes spotted sofar? Still don't get it, why the PIC won't run with the MAX232 disconnected. After all, it can run just with MAX232 alone connected without any data feed from the computer. Wonder if it's the hardware problem / circuit design problem. But the same circuit with different codes ran without problem. So guess must be the codes. Can Help?
:?: Am I missing the part that, whenever you include USART module, you must have MAX232 permanently hook on to it?

TimB
Posts: 262
Joined: Wed Oct 04, 2006 7:25 am
Location: London UK

Post by TimB » Sat May 10, 2008 7:21 am

If you have a bootloader on the pic it will look at the USART to see if there is any data coming in.

The USART idles high with out a 232 converter on it it will idle low and the USART will see data $FF and the bootloader will keep seeing that data and never move on.

Pull the Usart line high and see what happens.

Francis
Registered User
Registered User
Posts: 314
Joined: Sun Mar 25, 2007 9:40 am
Location: Devon

Post by Francis » Tue May 13, 2008 9:01 pm

CS I noticed the same the other day.
I assumed I couldn't read Data Sheets so did my own ADC read.

CS
Posts: 127
Joined: Thu Nov 02, 2006 9:14 am

Post by CS » Wed May 14, 2008 1:04 am

Hi Francis,

of course I made the changes for my own, but I think David will make the changes in the original modul and with the next update the little mistake is away!

I have to addmit, that I first thought that my pic is demaged because I was not able to use the external Vref. After long times of reading and testing I found the mistake.

Reguards

CS

User avatar
blueroomelectronics
Posts: 46
Joined: Mon Apr 23, 2007 3:48 pm
Location: Toronto
Contact:

Post by blueroomelectronics » Thu May 15, 2008 2:09 am

According to the 18F1320 the VREF+ reference must have a maximum impedance of 250ohms.

Post Reply