![]() |
![]() |
![]() |
|
|
|||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
|
|
Thread Tools | Display Modes |
|
|
(permalink) |
|
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 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.
|
|
|
|
|
|
|
(permalink) |
|
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. |
|
|
|
|
|
|
(permalink) |
|
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 |
|
|
|
|
|
|
(permalink) |
|
I only do Assembler and some C18 for 18F' devices. Sorry. But I'll look through my 16F88 code for examples for you.
Mike |
|
|
|
|
|
|
(permalink) |
|
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
Try adding OSCCON = %01110000 Mike. |
|
|
|
|
|
|
(permalink) |
|
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. |
|
|
|
|
|
|
(permalink) |
|
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. solid now. MAN this was a lot of work for something simple. I saved sooo much time using BASIC, AGAIN!!! Last edited by mramos1; 6th November 2006 at 10:08 PM. |
|
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Latest |
| Simple Physics Project | Tom McCurdy | Electronic Projects Design/Ideas/Reviews | 1 | 11th May 2005 02:23 PM |
| Choosing a PIC for my project... | Beef41 | Micro Controllers | 6 | 19th March 2004 03:46 PM |
| I need a project idea based on my strength or interest. :) | janetsmith2000@yahoo.com | Electronic Projects Design/Ideas/Reviews | 10 | 11th November 2003 09:33 AM |
| findin out for an innovative project | bewra | Electronic Projects Design/Ideas/Reviews | 2 | 26th September 2003 10:41 PM |
| Project idea | yon_emz | Electronic Projects Design/Ideas/Reviews | 1 | 21st April 2003 12:48 PM |