![]() |
![]() |
![]() |
|
|
|||||||
| 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) |
|
Please look over this rough schematic. This is my take on an adapter board taken off the firefly schematic. I hope this works. I just need it to program the 16F628A for now and don't need the "debugger". (not an EE) The hex code is already done, just have to load it up.
Oh, that 40pin is a 40p zif and the 3 pin header is for 8-18 pin pic's and 28-40 pin pic's for VPP. thanks Last edited by lemonyx; 1st May 2007 at 08:57 AM. |
|
|
|
|
|
|
(permalink) |
|
If it's from the Firefly shematic it'll work, I like the 40,20 pin jumper idea neat.
PS it can program the 20pin PICs in the 18 pin mode. PPS add a 0.1uf cap on the power, won't hurt. Suggest optionally the 40pin VPP could be hard wired, the 8-20 pin chips will never see it. So a simple switch or jumper would be all you need on the 8-20 VPP. Last edited by blueroomelectronics; 1st May 2007 at 12:33 PM. |
|
|
|
|
|
|
(permalink) |
|
Well, I've finished my Inchworm - looks good even for a hack like me (non EE).
I also built an adapter board for maybe when I graduate to other Pic's (wishful thinking) schematic is on the first post, with the board. Oh yeah, William, I added a cap .1uf as you suggested - it's on the backside. So with my new programmer and adapter bd I tred it out. Followed William's hello world instructions and got this failed message. HELP With the power applied, (13v dc wallwart) the power led comes on and my adapter led comes on (means that I got some power to the board anyway). I'm trying to program a 16F628A with this asm. I also have the hex file that has already been comverted. This is the error msg: Connecting to MPLAB ICD 2 ICD0019: Communications: Failed to open port: (Windows::GetLastError() = 0x2, 'The system cannot find the file specified. ') ICD0021: Unable to connect with MPLAB ICD 2 MPLAB ICD 2 Ready ICDWarn0034: Please ensure that your system's serial FIFO buffers are disabled. Connecting to MPLAB ICD 2 ICDWarn0054: MPLAB IDE has lost communications with the MPLAB ICD 2. Would you like to attempt to reconnect? Connecting to MPLAB ICD 2 ICD0021: Unable to connect with MPLAB ICD 2 MPLAB ICD 2 Ready Clean: Deleting intermediary and output files. Clean: Deleted file "C:\Documents and Settings\jahilee\My Documents\New Folder\ingrid.asm.mcs". Clean: Done. Executing: "d:\Microchip\MPASM Suite\MPAsmWin.exe" /q /p16F628A "ingrid.asm" /l"ingrid.lst" /e"ingrid.err" Warning[218] C:\DOCUMENTS AND SETTINGS\JAHILEE\MY DOCUMENTS\INGRID.ASM 1 : Expected DEC, OCT, HEX. Will use HEX Error[129] C:\DOCUMENTS AND SETTINGS\JAHILEE\MY DOCUMENTS\INGRID.ASM 2 : Expected (END) Halting build on first failure as requested. BUILD FAILED: Sun May 06 00:50:56 2007 My interpetation is that from #1 - to beginning of #4, in your hello world instructions, the Inchworm is NOT connected till #4b - where it says to "connect" (Inchworm Busy LED should flash) it doesn't but it does lit up when power is applied. HELP |
|
|
|
|
|
|
(permalink) |
|
Hee's a copy of the asm I'm trying to load up:
RADIX hex processor p16f628a LIST p=p16f628a LIST n=0 LIST r=hex LIST st=on LIST f=inhx8m include p16f628a.inc __CONFIG _BODEN_ON & _CP_OFF & _DATA_CP_OFF & _PWRTE_ON & _WDT_OFF & _LVP_OFF & _MCLRE_OFF & _INTRC_OSC_NOCLKOUT ; DAC control bits #define mswitch PORTA,0x05 #define hswitch PORTA,0x07 #define gridmsb PORTA,0x06 #define gridm2sb PORTB,0x02 #define _segper PORTB,0x07 #define gridpar grid,0x00 #define grswap grtmp,0x00 #define _is_pm ampm,0x00 #define _is_50 clkconfig,0x07 ; A<0:3>,B<4:7> - segments ; A<4> - 60Hz inputs ; A<5> - grid MSB ; A<6:7> - min:hr inputs ; B<0:2> - grid LSBs ; B<3> - PWM out ; 0x70 through 0x7f are mapped in all banks segsave EQU 0x60 seg2save EQU 0x61 sixtcnt EQU 0x62 ampm EQU 0x63 mswcnt EQU 0x70 hswcnt EQU 0x71 sixt EQU 0x72 seconds EQU 0x73 minutes EQU 0x74 hours EQU 0x75 grid EQU 0x76 sectmp EQU 0x77 mintmp EQU 0x78 hrtmp EQU 0x79 grtmp EQU 0x7A clkconfig EQU 0x7B dot1 EQU 0x7C dot2 EQU 0x7D dot3 EQU 0x7E dot4 EQU 0x7F ORG 0x00 ; initial setup bcf STATUS,RP0 ; bank 0 bcf STATUS,RP1 ; ... clrf PORTA ; clear port A goto $ + 0x02 ; (jump over the interrupt vector) goto intrh ; (interrupt vector) clrf PORTB ; clear port B movlw 0x07 ; move 0x07... movwf CMCON ; ...into cmcon to turn off comparators bsf STATUS,RP0 ; bank 1 bsf PCON,OSCF ; osc=4MHz movlw 0xB0 ; a<7,5:4> movwf TRISA ; are inputs movlw 0xF7 ; RB3 is output, movwf TRISB ; rest is input (for now) movlw 0x28 ; move 0xA8... movwf OPTION_REG ; into OPTION => pullups enabled, RB4 to TMR0, prescaler assigned to WDT ; set up PWM movlw 0x0F ; 0x0E goes into... movwf PR2 ; ...pr2 => (14+1)*4*Tosc = 200/3 kHz bsf PIE1,TMR2IE ; enable timer2 interrupt bcf STATUS,RP0 ; bank 0 clrf CCPR1L ; clear duty cycle for now (set below) movlw 0x0F ; 0x0F goes into... movwf CCP1CON ; ...ccp1con => cp1x=cp1y=0, PWM mode on movlw 0x7C ; 0x7C goes into... movwf T2CON ; ...t2con => 1/16 postscaler, 1:1 prescaler, t2 on ; clear memory locations we'll be using clrf segsave clrf seg2save clrf sixtcnt clrf ampm clrf mswcnt clrf hswcnt clrf sixt clrf seconds clrf minutes clrf hours clrf grid clrf sectmp clrf mintmp clrf hrtmp clrf grtmp clrf clkconfig clrf dot1 clrf dot2 clrf dot3 clrf dot4 ; do configuration stuff btfsc PORTB,0x06 ; if RB6 is high goto readconfig ; no resistor is installed, so we are in EEPROM setup mode movf PORTB,w ; otherwise, read in the PORTB value xorlw 0xFF ; invert the value (resistor installed = 0, want 1) andlw 0xB7 ; kill the values of RB6 and RB3 (these should always be zero) movwf clkconfig ; this is the clock configuration word goto docfgsetup ; now we're ready to set up the part ; read config word from EEPROM since we're not in resistor mode readconfig: bsf STATUS,RP0 ; bank 1 movlw 0x3F ; address 63 movwf EEADR ; into the EEPROM address register bsf EECON1,RD ; read the data movf EEDATA,w ; read the config word movwf clkconfig ; write it to clkconfig bcf STATUS,RP0 ; bank 0 ; now check status buttons for config updates btfss mswitch ; if the minutes button is being pushed bsf mswcnt,0x00 ; save the push state btfss hswitch ; if the hours button is being pushed bsf mswcnt,0x01 ; save the push state movf mswcnt,w ; load the button config btfsc STATUS,Z ; if no buttons were pushed (cfgbuttons == 0) goto docfgsetup ; setup the config registers and be done addlw 0xFE ; else add -2 to w btfsc STATUS,Z ; if result == 0 goto cfgmod2 ; cfgbuttons was 2 btfsc STATUS,C ; else if result == 1 (overflow of w + 254 means new result is positive) goto cfgmod3 ; cfgbuttons was 3 ;goto cfgmod1 ; else result == -1, so go to cfgmod1 ; ; clkconfig: ; H x M M x D D D ; ^ ^ ^ ^ ^ ^ ^ ^ ; | | | | | | | \ - \ ; | | | | | | \ - - -\ duty cycle for PWM ; | | | | | \ - - - -/ (4 + this number is duty cycle) ; | | | | | ; | | | | \ - - - - -> unused (for now!) ; | | | | ; | | | \ - - - - - -\ space mode (blank, complex, ; | | \ - - - - - - -/ simple '-', simple 'o') ; | | ; | \ - - - - - - - -> unused (for now!) ; | ; \ - - - - - - - - -> 50/60Hz operation (set = 50Hz) ; ;cfgmod1: change from 50Hz to 60Hz movlw 0x80 ; load 0x80 xorwf clkconfig,f ; flip the MSB of clkconfig goto writeconfig ; write the new config and continue ;cfgmod2: cycle through display modes cfgmod2: movf clkconfig,w ; load clkconfig andlw 0xBF ; be sure that bit 6 is blank addlw 0x10 ; add 1 to the top nibble movwf clkconfig ; write back incremented state (possibly overflowing into unused bit 6) goto writeconfig ; write the new config and continue cfgmod3: movf clkconfig,w ; load clkconfig andlw 0xF7 ; be sure that bit 3 is blank addlw 0x01 ; add 1 to the bottom nibble movwf clkconfig ; write back incremented state (possibly overflowing into unused bit 3) ;goto writeconfig ; write the new config and continue writeconfig: bsf STATUS,RP0 ; bank 1 bsf EECON1,WREN ; enable writing movlw 0x3F ; address 63 movwf EEADR ; into EEADR movf clkconfig,w ; load clock config into w andlw 0xB7 ; make sure that the data is valid movwf EEDATA ; write to eedata movlw 0x55 ; move 0x55 movwf EECON2 ; into EECON2 movlw 0xAA ; move 0xAA movwf EECON2 ; into EECON2 bsf EECON1,WR ; set the wr bit bcf EECON1,WREN ; disable further writes bcf STATUS,RP0 ; bank 0 docfgsetup: bsf STATUS,RP0 ; bank 1 clrf TRISB ; portB is all outputs bcf STATUS,RP0 ; bank 0 ; set up 50/60 Hz movlw 0x3C ; load 60 into w btfsc _is_50 ; if we're in 50Hz mode movlw 0x32 ; load 50 instead movwf sixtcnt ; write w to sixtcnt ; set up brightness movlw 0x07 ; 0b00000111 andwf clkconfig,w ; mask off duty cycle bits addlw 0x04 ; add 4 movwf CCPR1L ; this is our duty cycle ; set up display mode btfsc clkconfig,0x05 ; if clkconfig<5> goto $ + 4 ; pick which of the simple modes btfss clkconfig,0x04 ; else goto dointsetup ; clkconfig<5:4> == 0, blank goto cfgcomplex ; clkconfig<5:4> == 1, complex btfss clkconfig,0x04 ; ... goto cfgsimpd ; clkconfig<5:4> == 2, simple dash ;goto cfgsimpo ; clkconfig<5:4> == 3, simple o ;cfgsimpo: movlw 0x70 ; bottom 3 segments movwf dot1 ; into dot1 movlw 0x08 ; just bar movwf dot2 ; into dot2 movlw 0x70 ; bottom 3 segments movwf dot3 ; into dot3 movlw 0x08 ; just bar movwf dot4 ; into dot4 goto dointsetup ; done cfgsimpd: movlw 0x08 ; just bar movwf dot2 ; into dot2 movlw 0x08 ; just bar movwf dot4 ; into dot4 goto dointsetup ; done cfgcomplex: clrf dot1 ; dot1 empty movlw 0x0F ; top 4 segments movwf dot2 ; into dot2 movlw 0x70 ; bottom 3 segments movwf dot3 ; into dot3 movlw 0x08 ; just bar movwf dot4 ; into dot4 ;goto dointsetup ; done ; set up interrupts ;bsf PIE1,TMR2IE ; done above when we're already in bank 1 dointsetup: bcf PIR1,TMR2IF ; clear timer2 interrupt flag movlw 0xFF ; load -1 movwf TMR0 ; into tmr0 bcf INTCON,T0IF ; clear timer0 interrupt flag bsf INTCON,PEIE ; enable peripheral interrupts bsf INTCON,GIE ; enable interrupts ; busyloop---purely interrupt driven code nop goto $ - 1 ; loop forever intrh: ; check the min switch bcf STATUS,RP0 ; bank 0 btfsc mswitch ; if the minutes button is not being pushed goto checkhclr ; check hswitch and clear mswcnt incfsz mswcnt,f ; otherwise, increment mswcnt goto checkh ; if we didn't wrap around, check the hour switch goto dominute ; else do minutes checkhclr: clrf mswcnt ; clear the minute debounce counter checkh: ; check the hr switch btfsc hswitch ; if the hours button is not being pushed goto check60clr ; check the 60hz input and clear hswcnt incfsz hswcnt,f ; otherwise, increment hswcnt goto check60 ; if we didn't wrap around, check the 60hz input goto dohour ; else do hours check60clr: clrf hswcnt ; clear the hour debounce counter check60: ; check the 60Hz input btfss INTCON,T0IF ; if the t0if isn't set goto domux ; just do the mux ; handle sixt increment bcf INTCON,T0IF ; first, handle the timer stuff movlw 0xFF ; reset clkset value movwf TMR0 ; put it in TMR0 incf sixt,f ; increment sixt movf sixtcnt,w ; xor sixtcnt... xorwf sixt,w ; ...with sixt btfss STATUS,Z ; if sixt != sixtcnt goto domux ; just handle muxing clrf sixt ; clear sixtieths count ; handle second increment incf seconds,f ; increment seconds movlw 0x3C ; xor 60... xorwf seconds,w ; ...with seconds btfss STATUS,Z ; if seconds != 60 goto domux ; just handle muxing clrf seconds ; clear seconds count ; handle minute increment dominute: incf minutes,f ; increment minutes movlw 0x3C ; xor 60... xorwf minutes,w ; ...with minutes btfss STATUS,Z ; if minutes != 60 goto domux ; just handle muxing clrf minutes ; clear minutes count ; handle hour increment dohour: incf hours,f ; increment hours movlw 0x18 ; xor 24... xorwf hours,w ; ...with hours btfss STATUS,Z ; if hours != 24 goto domux ; just handle muxing clrf hours ; else clear hours domux: movlw 0x40 ; gridmsb movwf PORTA ; in porta movlw 0x04 ; gridm2sb movwf PORTB ; in portb incf grid,f ; increment the grid we're looking at movlw 0x08 ; xor 8... xorwf grid,w ; ...with grid btfss STATUS,Z ; if grid != 8 goto notdot ; not displaying the dot movlw 0xFF ; put 0xFF movwf grid ; in grid (next time it overflows to 0) ; handle am/pm dot clrf ampm ; clear am/pm movlw 0x0C ; load 12 subwf hours,w ; hours - 12 btfss STATUS,C ; if c is not set goto $ + 3 ; just do updates bsf _segper ; otherwise, we are PM, so set the period bsf _is_pm ; and the flag bcf gridm2sb ; clear the m2sb to set grid = 8 movf seconds,w ; load seconds movwf sectmp ; update sectmp movf minutes,w ; load minutes movwf mintmp ; update mintmp movf hours,w ; load hours movwf hrtmp ; update hrtmp movlw 0x0C ; load 12 btfsc _is_pm ; if it's PM subwf hrtmp,f ; subtract 12 from hrtmp movf hrtmp,f ; touch hrtmp register btfsc STATUS,Z ; if hrtmp is zero movwf hrtmp ; make it 12 instead goto theend ; done notdot: ; handle non-dot grids bsf STATUS,RP0 ; bank 1 movf grid,w ; load grid movwf grtmp ; save in grtmp btfss STATUS,Z ; is grid == 0? goto $ + 2 ; if no, go on goto secnum ; else display number for grid 0 decfsz grtmp,f ; is grid == 1? goto $ + 2 ; if no, go on goto secnum ; else display number for grid 1 decfsz grtmp,f ; is grid == 2? goto $ + 2 ; if no, go on goto disp2dash ; grid 2 is always a dash decfsz grtmp,f ; is grid == 3? goto $ + 2 ; if no, go on goto minnum ; else display number for grid 3 decfsz grtmp,f ; is grid == 4? goto $ + 2 ; if no, go on goto minnum ; else display number for grid 4 decfsz grtmp,f ; is grid == 5? goto hrnum ; if no, it must be 6 or 7; either one uses hrnum ;goto disp5dash ; grid 5 is always a dash ;disp5dash: btfsc sectmp,0x00 ; if seconds is odd goto topdot ; display the top dot goto botdot ; else display the bottom dot disp2dash: btfss sectmp,0x00 ; if seconds is even goto topdot ; display the top dot goto botdot ; else display the bottom dot topdot: bcf STATUS,RP0 ; bank 0 movf grid,w ; load grid iorwf dot1,w ; load in configured dots movwf PORTB ; write to port B movf dot2,w ; load in configured dots movwf PORTA ; write to port A goto theend ; we're done botdot: bcf STATUS,RP0 ; bank 0 movf grid,w ; load grid iorwf dot3,w ; load in configured dots movwf PORTB ; write grid and segments to PORTB movf dot4,w ; load in configured dots movwf PORTA ; into port A goto theend ; and we're done secnum: movf sectmp,w ; load seconds btfsc gridpar ; if grid is odd addlw 0x40 ; get the high digit (stored at offset 0x40 in EEPROM) movwf EEADR ; into the EEPROM address goto dataloaded ; common code for all displays minnum: movf mintmp,w ; load minutes btfss gridpar ; if grid is even addlw 0x40 ; get the high digit (stored at offset 0x40 in EEPROM) movwf EEADR ; into the EEPROM address goto dataloaded ; common code for all displays hrnum: movf hrtmp,w ; load hours btfsc gridpar ; if grid is odd addlw 0x40 ; get the high digit (stored at offset 0x40 in EEPROM) movwf EEADR ; into the EEPROM address ;goto dataloaded ; common code for all displays dataloaded: bsf EECON1,RD ; read data from EEPROM movf EEDATA,w ; load EEPROM data bcf STATUS,RP0 ; bank 0 movwf segsave ; save EEDATA to segsave andlw 0x0F ; mask off top nibble movwf seg2save ; save until later xorwf segsave,w ; XOR remaining bits with original data to get top nibble iorwf grid,w ; and then OR in the grid number movwf PORTB ; write PORTB bcf gridmsb ; turn off the grid MSB movf seg2save,w ; load PORTA value movwf PORTA ; write PORTA theend: bcf PIR1,TMR2IF ; clear timer2 interrupt flag retfie ; return from the interrupt END |
|
|
|
|
|
|
(permalink) |
|
Your Inchworm may not have the OS loaded, you must do this the first time you use your Inchworm. They come with the bootloader loaded and require the OS to be loaded too. Instructions are on page 7 of the Inchworm Assembly Manual.
Also MPLAB will not default to COM1 or COM2 when ever its run, you must select the COM port manually before you can connect. It will remember COM port setting when you are in a workspace. Lastly if you're using a USB to RS232 adapter there are good ones and bad ones, if it uses the PL2303 chipset then use the driver on my site not the one that comes with it. PS just noticed your PIC is inserted in the DIP socket in the wrong place, pin #1 goes to PIN 11 on the zif *you have it in pin 12 Last edited by blueroomelectronics; 6th May 2007 at 01:16 PM. |
|
|
|
|
|
|
(permalink) |
|
William
Thanks, I did forget to load the OS, duh? Will do |
|
|
|
|
|
|
(permalink) |
|
Hope that worked, you only need to do it once. MPLAB will do it automatically after that when it needs to.
|
|
|
|
|
|
|
(permalink) |
|
Well, I've followed the directions for downloading the OS for the Inchworm and no go.
This is the error msgs I get: Connecting to MPLAB ICD 2 ICD0019: Communications: Failed to open port: (Windows::GetLastError() = 0x2, 'The system cannot find the file specified. ') ICD0021: Unable to connect with MPLAB ICD 2 MPLAB ICD 2 Ready ICDWarn0034: Please ensure that your system's serial FIFO buffers are disabled. Connecting to MPLAB ICD 2 ICDWarn0054: MPLAB IDE has lost communications with the MPLAB ICD 2. Would you like to attempt to reconnect? Connecting to MPLAB ICD 2 ICD0021: Unable to connect with MPLAB ICD 2 MPLAB ICD 2 Ready Downloading Operating System ICD0021: Unable to connect with MPLAB ICD 2 ...Download Operating System Failed ICD0286: Unable to communicate with ICD ICD0286: Unable to communicate with ICD ICD0286: Unable to communicate with ICD ICD0286: Unable to communicate with ICD ICD0286: Unable to communicate with ICD MPLAB ICD 2 Ready After hooking up the inchworm, I go into Programmer - selcect programmer -MPLAB ICD2 Then go into settings and change from the USB to Com1 and the fifo buffer box is unchecked. (reboot) Then Configure - select device - PIC 16F877 no "A" is in the window. Go back into Programmer - download ICD2 OS - it's a hex file ICD1020701.hex The serial cable is hooked up and the power supply is attached as well. help!! Still doing something wrong?????? or missing a step |
|
|
|
|
|
|
(permalink) |
|
Also what type of USB serial adapter is it? If it's a PL2303 based adaper force install the drivers on my site or it won't work.
Else check the crystal is mounted very slightly off the PCB. |
|
|
|
|
|
|
(permalink) |
|
The cable is a serial cable about 6' long. No USB adapter used. When I put the crystal in I used some "shims" to keep it off the board, so there is a small gap there and not touching the board or shorting anything out.
It was a kit from DPmicro so hopefully the boot loader was installed. |
|
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Latest |
| More inchworm help needed | Andy1845c | Micro Controllers | 24 | 6th March 2007 12:40 AM |
| Inchworm built: Next step | Hedos | Micro Controllers | 3 | 17th December 2006 11:29 PM |
| [help]automotive adapter for labtop computer | fireman | Electronic Projects Design/Ideas/Reviews | 10 | 15th July 2006 10:27 PM |
| 110V 50HZ adapter | bandit | General Electronics Chat | 2 | 13th August 2004 08:00 AM |
| Adapter Question | Sceptre | General Electronics Chat | 5 | 20th November 2003 03:23 PM |