![]() |
![]() |
![]() |
|
|
|||||||
| General Electronics Chat This forum is for general chat about electronics, eg: Dont know what a part does? Dont know how to read a circuit? Want to get an opinion? |
|
|
Thread Tools | Display Modes |
|
|
(permalink) |
|
Hi to all,
Just got a PIC circuit built and programmed the PIC but got an error! The configuration says 3BF9 but when it writes that it comes up with an error saying the config is 3BFF! The PIC is a 16f84 and I have successfully programmed it before with my first program which was just a simple LED flasher, and that worked OK. However that program was a lot smaller than the Rev Counter program that I'm trying to do now so I wondered if a small part of a PIC can be faulty, maybe unable to be written correctly? The program I'm trying to use is the RevMaster Firmware Zip at http://www.jeffree.co.uk/pages/tachometer-pcbs.html I'm using the Velleman Pic Programmer with the Velleman Kit 8048 VM111 rev: 2.6.0. I have built the circuit from the site on PCB and checked it many times, though it's got so few components on it that its fairly easy to check, and I cannot find any fault, the LCD is new and is the 2 x 16 line one that is used on the site. I have tested with and without the slotted sensor which is on a separate plug in board, in case there was a problem with that, but I get absolutely nothing on screen. I have +v and ground at the circuits input pins and also at the connector for the sensor. Please take pity on a poor fool who was just getting used to conventional electronics when I decided to have a stab at PICs, and though the circuits are simpler to build they seem even harder to fault find on! DOH! Thanks for looking.............Al
__________________
Founder member of the Campaign to do Something about the none existant word "Somethink" |
|
|
|
|
|
|
(permalink) |
|
hi Al,
Look at this link. http://forum.velleman.be/viewtopic.p...29c61e604c4d39 The last digit in the two Configs you have posted are the WDT and the OSC selection. The link refers to jumpers on the programmer. Regards
__________________
Eric "Good enough is Perfect" PIC tutorials: Gramo's: www.digital-diy.net/ Bill's: www.blueroomelectronics.com/ |
|
|
|
|
|
|
(permalink) |
|
Al,
are you sure you have a 16F84 and not an 84A? I am not very advanced with PIC's, but when I have had similar problems in the past, it has sometimes been down to a processor mis-match. HTH. |
|
|
|
|
|
|
(permalink) |
|
Hi Eric and HTH,
Hello again Eric, hope you are well. As to the jumpers, they are as the guy said on the thread, they won't go on wrong (too big a gap between them) but they are on the 18 pin setting, which is for the 16F84. As to HTH's suggestion that I may have an "A" version, The Chip is marked "16F84-04/P" so I can only assume its an old pre A version. Anyway keep up the suggestions guys, no suggestion however strange will go unchecked! Regards.............Al
__________________
Founder member of the Campaign to do Something about the none existant word "Somethink" |
|
|
|
|
|
|
(permalink) |
|
I have had pics go a bit faulty in the past. I had a 16F886 and it's internal oscillator ran at 5.3MHz instead of 8. Have you a Maplin nearby where you could get a new one and at least eliminate the chip.
Mike. |
|
|
|
|
|
|
(permalink) | |
|
Quote:
Yeah there is a Maplins quite near but maybe they are different in the UK to OZ, here they simply say "sorry thats a web only item" BEFORE you actually tell them what you want! hehehe Seriously Mike, UK Maplins sell more radios than parts for radios and have virtually no stock, so you have to use the web service which costs a minimun postage of about 5 pounds for even a single chip. That said they are excellent at sending replacement parts out, I have had 5 elements die on me from my solder station so far, and they have sent them out really fast every time. So they aren't all bad I suppose! Anyway keep the suggestions going! Maybe there is someone out there who could convert a 16F84 hex file to say a 16F627, its certainly beyond me! Al
__________________
Founder member of the Campaign to do Something about the none existant word "Somethink" |
||
|
|
|
|
|
(permalink) |
|
hi Al,
Why dont you register with www.Farnell.com they have a wide range of products, any order over £20 is free post in the UK. They also have datasheets online for most of their stock items. Unless you must use the 16F84, have a look at the 16F628A version. Regards You have my home address, I could check out your 16F84 on my system.
__________________
Eric "Good enough is Perfect" PIC tutorials: Gramo's: www.digital-diy.net/ Bill's: www.blueroomelectronics.com/ |
|
|
|
|
|
|
(permalink) | |
|
Quote:
I also found many faulty pics with these problems. *some PICs internal RC not working. *some PICs doesn't support to XT OSC but can work with XT OSC. *some PICs some of GP registers not working. *some PICs the internal EEPROM not working. See how faulty are they. |
||
|
|
|
|
|
(permalink) |
|
Hi Eric and Gayan,
I have a few PICs laying around, but to me the problem of changing the code is insurmountable. I don't pretend to unerstand the Hex at all, I can just about understand the basic code if its not too complex. The problem with changing the programming is stopping me from using a different PIC, but maybe you know what I should change, and maybe could help me out. Farnell does seem to be useful and I will have a good look through their site, I usually order from Rapid or a little known one called Bits Box, which is excellent for prices on his stock but not as big as some ranges! Also thanks for the info on faulty pics, at least I know I may not be alone in having a non working Pic project. PS Eric, If you think you could help convert to another Pic, the ones I have are 16F872 - 16F874 - 16F627 - 16F630 (if the postman ever decides to bring them) and a good few 16F54 OTPs which I now believe have already been programmed! Doh! But since I was Given the 54s I can't really raise a ruckus over those. Can you program (or just read) the 54s with your programmer to test them I wonder as my new Velleman does not list them and my old Picstart 16 B1 thinks they are written, but I'm not certain its working 100% It would probable think a sheep was a big cotton bud! Thanks again guys...........Al
__________________
Founder member of the Campaign to do Something about the none existant word "Somethink" |
|
|
|
|
|
|
(permalink) | |
|
Quote:
Providing a .hex file somewhat protects the author's program. There are usually 3 basic forms of distribution of a program: 1) A code-protected chip is provided. (Highest - cannot be dis-assembled without specialist equipment, such as that which may be utilised by Microchip or Government agencies. *Speculation*) 2) A .hex file is provided, which anyone can program to the specified chip. (Medium - those with an intimate knowledge of Assembly could probably work out the program from a dis-assembly. Some of the Guru's on here may be able to do this. *again, Speculation*) 3) The source code is provided, which anyone can freely modify and/or utilise on other chips. (Lowest - no real protection to speak of - there are usually/sometimes terms specified, such as "You may freely modify this program, but please include credit to the original author." or "You may freely modify this program, but I take no responsibility for your toes turning black, your daughter getting pregnant or your dog getting sick." etc. etc.) If you really want this project to work for you and the original author is still active, drop him a line explaining your problem...he may be only too happy to help. HTH. |
||
|
|
|
|
|
(permalink) |
|
The source code is available but is in Unicode. Here it is in plain text for anyone who fancies converting to another compiler.
Code:
//
// Rev counter
//
#include <P16f84.h>
#include <displays.h>
//
// Define software version strings
const unsigned char VersionString1[]="V1.02";
const unsigned char VersionString2[]="19/02/2006";
#include "RevCount-vars.h"
// FUNCTION PROFORMAS
void clearLCD(); //Clear LCD display
void LCDNum(); //Output 5-digit revCount number to LCD
void Interrupt(); //Interrupt handler
//Time delay
void waitTime(unsigned int time);
//MAIN
//
void main ()
{
//Initialise Port A
TRISA=0x17; //Set all bits of Port A to input
// Initialize the LCD with startup message
waitTime(1000); //Wait a bit
LCD(-2); //2-line display, 8-bit, 5x7 format
clearLCD(); //Initialize & clear screen
LCDPrintAt(0,0); //2nd message
LCDString("RevMaster"); //Hello to the world
LCDPrintAt(0,1); //2nd line
LCDString (VersionString1); //Display software version
waitTime(32767); //Wait some more
LCDPrintAt(0,1); //2nd line
LCDString (VersionString2); //Display software date
waitTime(32767); //Wait some more
LCDPrintAt(0,1); //2nd line
zeros=5; //assume 1ppr and therefore 1 trailing zero
scale=6; //...and scale result by 6
if (PA.B0==0)
{
LCDString("06"); //6 marks per rev
zeros=5; //...therefore 1 trailing zero
scale=1; //...and scale by 1
}
else if (PA.B1==0)
{
LCDString("60"); //60 marks per rev
zeros=6; //...therefore 0 trailing zeros
scale=1; //...and scale by 1
}
else LCDString("00"); //60 marks per rev
LCDString(" PPR "); //
waitTime(32767); //Wait a bit
LCDPrintAt(0,1); //2nd message
LCDString(" 0 RPM"); //assume 1 mark per rev
LCD(0x104); //Force reverse cursor for number printing
//Initialise Port B and Interrupt settings
TRISB=0x01; //Set bits 1 to 7 of Port B to output,
//bit 0 to input
OPTION_REG=0x85; //Pull ups on B, TMR0 internal, 64 prescale
INTCON|=(1<<T0IE)|(1<<GIE)|(1<<INTE);
//Enable interrupts for TMR0 & INTE
// MAIN CONTROL LOOP - Select major mode & execute that mode's behaviour
while(1) //Loop forever
{
if (timeInt) //If there has been a 1/10th second interrupt
{
timeInt=0; //Clear the int flag
actual=countHi;
actual=(actual<<8)+countLo;
//Get the count value
countLo=0; //Clear the count value
countHi=0;
actual=actual*scale; //Scale the value by 1 or 6
LCDNum(); //Print the value
LCDPrintAt(16,1); //Lose the cursor
}
}
};
//
// Waittime function - waits for a specified delay period.
//
void waitTime(unsigned int time)
{
while(time--) ; //Repeat loop time times
};
//
// LCD Clear function
//
void clearLCD()
{
LCD(0x108); //Display off
LCD(0x101); //Clear display, cursor home
LCD(0x10f); //Display on, cursor on, flash cursor
LCD(0x180); //Print position 0,0
};
//
// LCDNum function - prints 4 digit revCount to LCD display (backwards)
// Includes decimal point if the point parameter is within range of digits
//
void LCDNum()
{
char digits;
LCD((int)zeros-1+0x180+0x40); //Print position zeros,0
for(digits=5; digits; digits--)
{
LCD((actual%10)+'0'); //Print Nth digit
actual/=10; //lose Nth digit
}
};
//
//Interrupt handler
//Interrupt generated every 1/50 secs by timer 0
//and every time a pulse is detected on Port B bit 0
//
const int QuickInt=1; // Flag use of quick interrupts
void Interrupt()
{
#asm
btfss INTCON,INTF ; If tacho interrupt...
goto noTach
incfsz countLo ; Increment low count
goto clearTach
incf countHi ; Increment high count if necessary
clearTach:
bcf INTCON,INTF ; Clear tacho interrupt...
noTach:
btfss INTCON,T0IF ; If timer interrupt...
goto noTimer
decfsz sec ; Decrement seconds count
goto clearTimer
movlw 1
movwf timeInt ; Signal a timer interrupt
movlw 50
movwf sec ; Re-prime the timer
clearTimer:
bcf INTCON,T0IF ; Clear timer interrupt...
noTimer:
#asmend
}
Mike. Last edited by Pommie; 29th March 2008 at 03:45 AM. |
|
|
|
|
|
|
(permalink) |
|
Hi everyone,
Thanks for all the help, I've finally solved the problem. I think it was due to the fuse settings which on ProgPic 2 seem to be different to all the other programmers. IE there are more of them and they do not say what they are for, anyway after fiddling with them and trying different ID numbers I got it working! Don't know why ProgPic 2 has to be different to all the other programmers though, so if anyone does know please fill me in. Thanks again all.................Al
__________________
Founder member of the Campaign to do Something about the none existant word "Somethink" |
|
|
|
|
|
|
(permalink) |
|
Al,
if you want to gain a better insight into the CONFIG settings and how they translate to a hex value, have a look at the datasheet for your 16F84, here: http://www.ortodoxism.ro/datasheets/...hip/30430c.pdf and refer to section 8 - "Special Features of the CPU." sub-section 8.2 - "Configuration bits." Using VELLEMAN PIC PROGRAMMER (not PicProg2006) you can click the "View/Set" button within the Configuration area on the main screen, where you will be presented with a dialog box showing the 14 bits of the Config Word. A checked box represents a 1 and an unchecked box represents a 0. e.g. Your 3BF9 & 3BFF translate to 11101111111001 and 11101111111111 respectively. From the datasheet, you will note that 3BF9 disables the WDT and selects XT (external crystal) oscillator, whereas 3BFF enables the WDT and selects RC (Resistor Capacitor) oscillator. The PCB layout in the linked PDF has an external crystal oscillator (XT) and the supplied hex file most likely contains 3BFF, but having the choice to select differing config options, within the main screen of PicProg2006, has probably led to the confusion. Given the choice of the two Velleman programming softwares, when using a supplied hex file from a project, I would say probably the best option is to use VELLEMAN PIC PROGRAMMER and uncheck the "Write Config.Word" box. HTH. |
|
|
|
|
|
|
(permalink) | |
|
Quote:
Clearly WDT needs to be disabled, as the source shown never clears the WDT. So the 3BF9 makes more sense than 3BFF. Mike |
||
|
|
|
|
|
(permalink) | |
|
Nice one! Tell tale sign that WDT needs to be disabled, or the pic would keep resetting on WD
-BaC Quote:
__________________
Error: {Panic!} when trying to load: [reality shell]. kernel: "universe has been halted"... Information Underground |
||
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Latest |
| Olimex ICD2 Broken! | HerbertMunch | Micro Controllers | 43 | 5th February 2008 02:39 AM |
| HD44780 lcd help | jay543_uk | Micro Controllers | 12 | 8th November 2007 03:26 PM |
| PIC ASM - Summation two 16 bit numbers (16f84) | byrusber | Micro Controllers | 10 | 28th October 2007 08:40 PM |
| RS232 Converter | e.chain | Micro Controllers | 0 | 6th October 2007 06:19 PM |
| faulty digital components testing,checking | walters | General Electronics Chat | 5 | 22nd August 2005 07:10 PM |