Still no luck on a simple 16F88/ICD2 project

Status
Not open for further replies.

mramos1

Active Member
This is sort of a repeat. I have a simple circuit (attached sorry such a poor drawing). I wanted to play with the ICD2, MPLABs, MikcroBASIC and the new to me 16F88. Last weekend was a waste. I had the ADC work fine. Now that stopped working. Any mikcrobasic folks on electro-tech?

If I can get a sample of the 16F88 ADC I will probably go assember. Mike K8LH I think I am tring to many new things, but I would have to think the PIC is not configured right.

I import the raw .hex file and all works well. Just something is not configured correct I guess. Also, running 8Mhz now and on 3V (2 AA batteries)

Code:
program P16f88
'   8 Mhz internal OSC
    Symbol LED = 0
    Symbol POT = 0
    dim count as word
main:
 intcon=0         'interupt are disabled
 ansel=%00000001  'an0 port is analog mode others are in digital mode. page 113
 trisa=1          'port a0 is input others are output
 trisb=0          'all port b are output
 adcon0=%11000001       ' page 114
 adcon1=%10000000       ' page 115

    DO
    count=adc_read(POT)
    count=count
        ClearBit(PORTB,LED)
    VDelay_MS(count)
    count=adc_read(POT)
    count=count
        SETBIT(PORTB,LED)
    VDelay_MS(count)
  LOOP until 1 = 0
end.
 

Attachments

  • new5.jpg
    17.4 KB · Views: 403
Are you aware that for the debugger to work if requires certain memory locations. In the case of the 88 they are 0x70, 0xF0, 0x170, 0x1F0, 0x1E7-0x1EF and program memory 0xF00-0xFFF. I don't know how you tell your compiler to reserve these but there must be a way. I also think you need a NOP at location zero but I can't find this in the help file at the moment.

HTH

Mike.
 
Hey Mike, I am back on this thing again.

The one variable I have is at 0x20/21, looks like they are using 0xA0 (I think it was).

But I even program and release from reset and it is a no go.. I figured the ad_registers are wrong, and I read over them a couple time. What is weird if I take one of them out the ADC works.

At this point just running it from the programmer not debugger would make me smile. I have wasted 2 hours this weekend on it and just do not see the problem.

Mike
 
I only do Assembler and some C18 for 18F' devices. Sorry. But I'll look through my 16F88 code for examples for you.

Mike
 
Hi Mike (Mramos - too many Mikes around here!)

When you said "I import the raw .hex file and all works well." I assumed you could get it working fine stand alone but not with the debugger.

Looking at your code, I am not sure what you are trying to do.

Are you trying to make an LED flash slow/fast dependent on the ADC input? If so, then your code should work.

Or, are you trying to make it come on above a certain value, if so, try
Code:
  DO
    count=adc_read(POT)
    if count > 512 then
        ClearBit(PORTB,LED)
    else
        SETBIT(PORTB,LED)
    end if
  LOOP until false

You also state that your using the 8MHz int osc but don't set OSCCON.
Try adding OSCCON = %01110000

Mike.
 
Pommie,

Yea, just tring to make the LED go faster and slower off the ADC.. It has been a pain. I have a lot of variable in there. I will try the OSCCON. I did not notice that in the ASM.

Also, everything works well but the actual program doing what it is supposed too.
 
Pommie.

That is it. Well two things. OSCCON was not set by the compiler, looked at disassembly.

I have done a 12F509 project and also a 16F683 and set OSC speed in the compiler and it worked. Other problem I think was a config, RB0 was set an CCP1 or something like that. I moved that to RB3. Bill told me last weekend use RB3 for LED PWM.. Had I done that I would have been closer.

It is running. New problem, if I release from reset it runs, and resets since I see the speed change. reset, new adc, etc. Maybe a decoupling cap. If it on a proto board, 8Mhz and ICD2 hook into it as well. Gonna look into that. I do not have MCLR pulled up. And I have the inchworm still in the circuit.

EDIT: New batteries, life is good. Now I need to add FET output to the LED. Then I will go to PCB and debug off that. And it will have a ICD connection and a jumpers to drop out VDD and MCLR too. Just in case. But it is rock
solid now. MAN this was a lot of work for something simple. I saved sooo much time using BASIC, AGAIN!!!
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…