Code Sharing!

How bout everyone shares the code the have wrote for the 16f627 and the development board, it might help out us begeinners to see how other people do things! just an idea!

I agree, I have the K8048 and 16F627 and I am finding it difficult to find any specific information. I am able to edit very slightly the sequences of lights in the demos but can’t find any specific projects for the K8048 and the 16F627 nor can I find info on what i would have to set up in terms of circuitry if i wanted to run the PIC outside of the programmer board.

Any information would be appreciated. Thanks

Hi folks,

have a look here:
winpicprog.co.uk/pic_tutorial.htm
…for tutorials (Code and Hardware) suitable for the 16F627.

The author uses a 16F628, but if you have a look at the datasheet, here:
ww1.microchip.com/downloads/en/D … 40300C.pdf
…you can see that the instruction set is the same for both PIC’s. You should change the include files, in the header, to tell the assembler that you are using a 627 instead of a 628.

The .asm files are available within each tutorial page, as a zip file, for downloading so that you don’t have to copy & paste.

You will have to spend some cash on stripboard, a spot-face cutter, header pins and plugs, ribbon cable, LED’s & switches, capacitors & resistors, a LM7805 voltage reg, and if you don’t already have one…a soldering iron.

This is just for starters…if you want to make up the other tutorial boards, you will also need to buy LCD modules, MAX232 IC’s, 9 pin D-Subs, etc.

HTH,

Mickster

Hi there, i’ll check those out, I already have everything you have listed there or a suitable alternative. Is the voltage regulator necessary if I am going to be running from a 9V or some other cells.

Also, you didn’t mention any crystals, i take it it’s possible to set up these circuits without using an external crystal? Any more info on this? thanks

neo,

the author’s tutorial board for the 16F628 (627 in your case) doesn’t specify any crystal in the parts list, or the schematic, so he’s obviously using the internal osc…look within the header :wink:

‘__config 0x3D18’ is a clue.

As for the voltage reg, I’m assuming it’s for keeping the supply to the PIC at 5v, regardless of input supply voltage…have a look at the datasheet for the regulator.

The voltage reg can be used with a battery-supplied application and still supply 5v as the cells discharge. I suppose this situation is preferrable when used with a supply voltage monitoring system, to alert the user when the supply voltage is low and the battery needs replacing.

When you get as far as making the LCD tutorial board, let me know if you find out how to modify the code to make an interactive menu, as I’m damned if I can figure it out!!

We could do with some more advanced members on this forum…

[quote=“Mickster”]neo,

the author’s tutorial board for the 16F628 (627 in your case) doesn’t specify any crystal in the parts list, or the schematic, so he’s obviously using the internal osc…look within the header :wink:

‘__config 0x3D18’ is a clue.

As for the voltage reg, I’m assuming it’s for keeping the supply to the PIC at 5v, regardless of input supply voltage…have a look at the datasheet for the regulator.

The voltage reg can be used with a battery-supplied application and still supply 5v as the cells discharge. I suppose this situation is preferrable when used with a supply voltage monitoring system, to alert the user when the supply voltage is low and the battery needs replacing.

When you get as far as making the LCD tutorial board, let me know if you find out how to modify the code to make an interactive menu, as I’m damned if I can figure it out!!

We could do with some more advanced members on this forum…[/quote]

I agree about needing more advanced members.

Do you know where i can find info on what configs the HEX value refers to or atleast what hex number each config is worth so i can work it out? To me that is a hex number that i can convert to binary, octal or decimal in my head but as a config it means nothing to me.

I’ll be taking a little break cause i’m off to Turkey with my girlfriend for a couple of weeks in a few hours for a hol so wont be doin anything till i’m back.

Wow, I feel cool now, I didn’t think such geeky people that know what Assembler is were allowed to say the word girlfriend :lol:

Peace out guys, and keep any ideas coming, i’ll get all those boards made soon as i get back.

Regarding the hex values of the configuration bits, refer to the datasheet in section 14 “Special Features of the CPU.”

Obviously, using the “View/Set” configuration option in the Velleman PIC Programmer, clicking boxes, you can decode which of the 14 bits are enabled/disabled in the configuration word, when a program listing only shows a HEX value.

Or, you could simply convert HEX to binary…
11110100011000
…and look at the datasheet.

In this case, 0x3D18 equates to:
bit13 1 (2k Code protection off)
bit12 1 (2k Code protection off)
bit11 1 (1k Code protection off)
bit10 1 (1k Code protection off)
bit09 0 (Unimplemented)
bit08 1 (Data code protection off)
bit07 0 (LVP disabled)
bit06 0 (Brown-out detection reset disabled)
bit05 0 (MCLR function is digital input on RA5)
bit04 1 ((in conjunction with 01 & 00) INT OSC with I/O on RA6 & RA7)
bit03 1 (PWRT disabled)
bit02 0 (WDT disabled)
bit01 0 ((in conjunction with 04 & 00) INT OSC with I/O on RA6 & RA7)
bit00 0 ((in conjunction with 04 & 01) INT OSC with I/O on RA6 & RA7)

The datasheet really is a requirement…I’m learning from it each time I pick it up…in fact, I’ve learnt some more from writing this post!

HTH,

Mickster

the 5v regulator is necessary to protect the chip as is should not be use dwith an over 5v supply. i too have a k8048 programmer board, but understand little of the code. any help and advice would be appreciated

I had made a post at the weekend, which included the original Demo2.asm code along with my own comments about many of the steps within the program, and a substitute routine for when SW4 is pressed.

Also included within the post, were many valuable links to tutorials where users could actually learn something about PIC MCU’s.

Unfortunately, the post has been deleted and attempts to contact a Moderator have proved futile, as Private Messages are disabled on this forum. Since no reason has been submitted, within this thread, as to why the post has vanished, I can only assume that Velleman don’t want their entire code listing for public viewing.

Soooooo…I will re-post the substitute code for the section at the end of Demo2.asm listed as ‘EFFECT_4’, and hope that David Copperfield doesn’t get his hands on it!

Highlight & copy the code listed below, then open the original Demo2.asm file and highlight from ‘EFFECT_4’ down to the line above ‘end’. Right-click and choose ‘Paste’, to replace the original routine. Assemble the ‘new’ Demo2.asm and flash it to the PIC.

What the routine does, is to count from 0, up to 63, displaying the result as binary on LED 1 to LED 6. When 63 is reached, the routine loops around to start from 0 again.

If this post is deemed to be in contravention of forum rules, could a Moderator at least have the courtesy to edit out the offending part(s) and include a reason.

Thanks in advance…and now to the code:

EFFECT_4 BTFSC PORTA,SW4 ;Test if SW4 released GOTO EFFECT_4 ;if not...re-test SW4 CLRF PATERN ;CLeaR 'F'ile reg "PATERN" E4 CALL DELAY_ROUTINE ; MOVLW D'00' ;Put 00 in 'W' register MOVWF PATERN ;Copy 00 into "PATERN" E5 MOVF PATERN,W ;Move "PATERN" to 'W' MOVWF PORTB ;Show "PATERN" on LED's CALL DELAY_ROUTINE ; CALL DELAY_ROUTINE ; CALL DELAY_ROUTINE ; CALL DELAY_ROUTINE ; INCF PATERN,F ;Add 1 to "PATERN" MOVF PATERN,W ;Move "PATERN" value to 'W' XORLW 0x40 ;Compare 'W' with 64 decimal BTFSC STATUS,Z ;if 'Z'ero, "PATERN" was 64 GOTO E4 ;Z set, so start again from 00 GOTO E5 ;Z not set, show "PATERN"+1

HTH,

Mickster.