18F4550 issue with simple program.


Closed Thread
Results 1 to 12 of 12

Hybrid View

  1. #1
    Join Date
    Feb 2004
    Location
    Michigan, USA
    Posts
    305


    Did you find this post helpful? Yes | No

    Default Re: 18F4550 issue with simple program.

    I cant seem to get some of the ADC readings to write to EEPROM. Channels 0 and 1 work perfectly the others write anything. Any idea whats going on? I think all the ports are set correctly.

    Define OSC 48
    Define ADC_BITS 10 ' Set number of bits in result
    Define ADC_CLOCK 3 ' Set clock source (3=rc)
    Define ADC_SAMPLEUS 50 ' Set sampling time in uS

    adval var word ' Create adval to store result
    adval1 var word
    adval2 var word ' Create adval to store result
    adval3 var word
    adval4 var word ' Create adval to store result
    adval5 var word

    TRISA = %11111111 ' Set PORTA to all input
    ADCON1 = %00000000 ' Set PORTA analog and right justify result
    ADCON2.7=1
    TRISB = %00011111
    TRISC = %00000000
    TRISE = %00001111
    RCSTA.7 = 0


    loop1:
    ADCIN 0, adval
    pause 1
    write 0, adval

    adcin 1, adval1
    pause 1
    write 1, adval1

    adcin 2, adval2
    pause 1
    write 2, adval2

    adcin 3, adval3
    pause 1
    write 3, adval3
    adcin 4, adval4
    pause 1
    write 4, adval4

    adcin 5, adval5
    pause 1
    write 5, adval5


    SEROUT PortC.6,2,[adval, adval1, adval2, 10]

    portc.6 = 0
    portc.7 = 0
    pause 200
    goto loop1
    End

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,644


    Did you find this post helpful? Yes | No

    Default Re: 18F4550 issue with simple program.


    adval var word ' Create adval to store result
    adval1 var word
    adval2 var word ' Create adval to store result
    adval3 var word
    adval4 var word ' Create adval to store result
    adval5 var word
    .............................

    pause 1
    write 0, adval

    adcin 1, adval1
    pause 1
    write 1, adval1

    how many bytes in a word ?

  3. #3
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: 18F4550 issue with simple program.

    Jmgelba, you need to index the memory pointer by 2 for it to store a word or, something like this:

    write 1, adval1.lowbyte
    write 2, adval1.highbyte

    then you can read them back by using:
    READ 1,value to read the entire word.
    Dave Purola,
    N8NTA
    EN82fn

Similar Threads

  1. USB issue - 18F4550
    By Scampy in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 20th February 2013, 20:49
  2. 18F4550 issue
    By Christopher4187 in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 4th February 2013, 06:27
  3. Simple LED driving issue - setup?
    By George in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 28th March 2011, 01:54
  4. Code issue with a flashing light(simple question)
    By IAmTheAnswer in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 8th May 2010, 11:46
  5. Simple 4 line LCD display with 18F4550
    By pic-ker in forum Code Examples
    Replies: 4
    Last Post: - 9th April 2007, 02:58

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts