Post your code and configs so we can see what you have done.
Post your code and configs so we can see what you have done.
Dave
Always wear safety glasses while programming.
Hi,
Thanks for taking the time to look. I tried to reply earlier, but I guess something went wrong, but if another post pops up just ignore that one....
I have not got any code yet as I have been trying lots of different things to get this to work. I have been trying for a week now to no avail. I just can't get anything to happen.
I had a lot of problems with a PIC16F690 before, until I set ANSEL and ANSELH. I guess it is something like this again, but I cannot find what, and have almost given up.
I thought I'd try this forum to see if anyone else had used thie 18F4523, and if so what they did to set it up.
As for code, I guess I would do something like this:
LH:
PortB.3 = 1 '(just an example, any port would do!!!)
Pause 1000
PortB.3 = 0
Pause 1000
Goto LH
End
But I know I have to set up the outputs, Osc etc first and this is where I am getting stuck. I have tried so many different variations but I am not getting anywhere.
I guess I should really keep looking through the 380 pages of the data sheet, and eventually I may come accross what I'm after, but I am new to this and was hopeing not to have to spend another few weeks before I can get anything to happen....
As for the harware, I have just got the VDD connected to +5v and VSS connected to GND (both sets of VDD and VSS). I am using 10Uf, and 100nf decoupling capacitors. For the outpt I am just looking at various pins using a volt meter. I am programming it using a Pickit II programmer, and I am not sure what pinout I am using for this as I have not got the circuit with me at the moment.
So in short I have not got the experience to go through the data sheet to find the info that I need, Please help!. Once I have something that I know should work I can use this to see if my hardware setup is fine, ie not missing any pullups etc (I think I tried MCLR pullup once).
Thanks.
ADCON1 configures analog or digital operation on this device.
As a note, I was really confused at first when I went to get the datasheet. It was only 54 pages! Well it seems they have a big note at the beginning explaining this is just the differences between this and another chip. Further they want me to use that datasheet except for the parts listed in the 54 page sheet. Anyway, the A/D stuff is in the "short sheet" So I suspect you are reading the other one as stated by you it is 380 pages.
-Bert
The glass is not half full or half empty, Its twice as big as needed for the job!
http://foamcasualty.com/ - Warbird R/C scratch building with foam!
Sorry you found that already. I deleted post.
Last edited by Brian; - 17th February 2011 at 14:36.
This should work on an 18F2320. I have tons of code working on this chip but I don't have a way to program or test it here at work.
I did have a copy of an old file I was playing with and I edited it and posted it here.
Also, you need to use MPASM to compile your code with this chip. I am not sure about the 18F4523 but I would think it would too. You can select that option in MicroCode studio under options.
As you figured out before the datasheet is the best way to understand how to setup a chip. Setting or configuring the chip you are using can be difficult when you first start but after you get the hang of it and use the data sheet it gets easier.
'************************************************* ***************
'* Name : 18f2320 *
'* Author : [set under view...options] *
'* Notice : Copyright (c) 2005 [set under view...options] *
'* : All Rights Reserved *
'* Date : 2/14/2005 *
'* Version : 1.0 *
'* Notes : *
'* : *
'************************************************* ***************
DEFINE OSC 4
OSCTUNE = 0 ' at calibrated frequency so not offset
OSCCON = %01100000 'OSC at 4Mhz
@ __CONFIG _CONFIG1H, _INTIO2_OSC_1H & _IESO_OFF_1H ' use internal osc
@ __CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_ON_2L
@ __CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
@ __CONFIG _CONFIG3H, _MCLRE_OFF_3H & _PBAD_DIG_3H & _CCP2MX_OFF_3H
@ __CONFIG _CONFIG4L, _LVP_OFF_4L
ADCON0.0 = 0
ADCON1 = %11001111
CMCON = 7 'comparators off
CVRCON = 0
LVDCON = 0
'set pins for output
trisb = 0
trisc = 0
trisa = 0
LED var portb.7 ' could be any pin you want here all configured for outputs
'varible declarations
'constants
'set variable and misc.
goto endsub
endsub:
main:
high led
pause 200
low led
pause 200
end
Thanks for all the replies.
I have just checked my microcode studio and it is currently using MPASM, thanks for the pointer though, if this was set wrong I would have never found it...
I'll have a play with the code posted tomorrow, and post how I get on.
Cheers,
AD.
Still cannot get anything to work with this PIC18f4523.
My code is (at the moment...):
DEFINE OSC 8
OSCCON = %01110000
ADCON0 = %00000000
ADCON1 = %00001111
CMCON = %00000111
TRISE=0
TRISD=0
PORTE.0 = 1
PORTD.2 = 1
I have tried various different things all day but I still cannot get any output.
I cannot try the code Brian supplied as it was for a different PIC (well, I did try it but it did not compile with the @__... lines in place, once I'd rem'd them out it programmed fine but still did not work). I can't use a 18F2320 as this has not got enough pins for the final project I want to use this pic for, and ideally I would like at least 1 12 bit adc, preferably 2.
Bookmarks