PDA

View Full Version : Newbie - failed at the first hurdle on Mels RTC!



hu lee gan
- 16th March 2011, 18:22
Hi All,
I'm a noob here so please be gentle with me 'til I get the hang of things (please!) - lol
I've tried compiling Mels Real time clock program as I want to build a clock circuit & I got these errors:

PICBASIC PRO(TM) Compiler 2.47, (c) 1998, 2006 microEngineering Labs, Inc.
All Rights Reserved.
PM Assembler 4.08, Copyright (c) 1995, 2006 microEngineering Labs, Inc.
Error C:\PBP\MELS_C~1.ASM 166 : [225] Undefined Symbol 'pic16F628'
Error C:\PBP\MELS_C~1.ASM 172 : [225] Undefined Symbol 'pic16F628'
Error C:\PBP\MELS_C~1.ASM 178 : [225] Undefined Symbol 'pic16F628'
Error C:\PBP\MELS_C~1.ASM 184 : [225] Undefined Symbol 'pic16F628'
Error C:\PBP\MELS_C~1.ASM 190 : [225] Undefined Symbol 'pic16F628'
Error C:\PBP\MELS_C~1.ASM 196 : [225] Undefined Symbol 'pic16F628'
Error C:\PBP\MELS_C~1.ASM 202 : [225] Undefined Symbol 'pic16F628'
Error C:\PBP\MELS_C~1.ASM 208 : [225] Undefined Symbol 'pic16F628'
Error C:\PBP\MELS_C~1.ASM 272 : [225] Undefined Symbol 'CMCON'
Error C:\PBP\MELS_C~1.ASM 272 : [225] Undefined Symbol 'CMCON'
Error C:\PBP\MELS_C~1.ASM 272 : [225] Undefined Symbol 'CMCON'
Error C:\PBP\MELS_C~1.ASM 272 : [225] Undefined Symbol 'CMCON'
Error C:\PBP\MELS_C~1.ASM 272 : [225] Undefined Symbol 'CMCON'
Warn C:\PBP\MELS_C~1.ASM 750 : [102] Code Crosses Boundary @ 800h
*** 13 Errors ***


So I changed all references for pic16F628 to pic16F887 and tried again, this time I get the following errors:

PICBASIC PRO(TM) Compiler 2.47, (c) 1998, 2006 microEngineering Labs, Inc.
All Rights Reserved.
PM Assembler 4.08, Copyright (c) 1995, 2006 microEngineering Labs, Inc.
Error C:\PBP\MELS_C~1.ASM 272 : [225] Undefined Symbol 'CMCON'
Error C:\PBP\MELS_C~1.ASM 272 : [225] Undefined Symbol 'CMCON'
Error C:\PBP\MELS_C~1.ASM 272 : [225] Undefined Symbol 'CMCON'
Error C:\PBP\MELS_C~1.ASM 272 : [225] Undefined Symbol 'CMCON'
Error C:\PBP\MELS_C~1.ASM 272 : [225] Undefined Symbol 'CMCON'
Warn C:\PBP\MELS_C~1.ASM 750 : [102] Code Crosses Boundary @ 800h
*** 5 Errors ***

I've tried searching for answers on here and have found the solution to the boundry error, but I can't figure out or find any info about the other errors I'm receiving? I would post the code, but it's exactly as I downloaded it from here!
Any help or pointers would be very much appreciated, thank you.

Archangel
- 17th March 2011, 01:29
Hello hu lee gan,
Welcome to the forum,
For starters, you could make our lives much easier if you were to post the link to the source code so we do not have to hunt and hope we are looking at the correct code. Thank You.

Ok the code as loaded into Microcode Studio should be something like this:


' Olympic Timer
' =============
' Melanie Newman
' 05/Aug/2004
' Topical Program demonstrates use of Interrupt
' Driven Background TIMER, to time events down to
' one one-hundredth of a Second (1/100 Sec).
'
' Bonus CALIBRATION Feature allows simple adjustments
' in 360mS steps per hour. This calibration adjustment
' range is limited to +/- 36 seconds per Hour.
'
' This program is for 4MHz clock (1uS Timer Ticks).
'
' PIC Defines
' ===========
'
' Change these defines to suit your chosen PIC
'
@ DEVICE pic16F876, XT_OSC ' System Clock Options
@ DEVICE pic16F876, WDT_ON ' Watchdog Timer
@ DEVICE pic16F876, PWRT_ON ' Power-On Timer
@ DEVICE pic16F876, BOD_ON ' Brown-Out Detect
@ DEVICE pic16F876, LVP_OFF ' Low-Voltage Programming
@ DEVICE pic16F876, CPD_OFF ' Data Memory Code Protect
@ DEVICE pic16F876, PROTECT_OFF
' Program Code Protection
@ DEVICE pic16F876, WRT_OFF ' Flash Memory Word Enable
'
' Hardware Defines
' ================
'
' LCD
' . . . . and so on and so forth . . .
The computer before me right now does not have MCS installed so bear with me . . . in the tool bar at the top is a list box where you are supposed to select the PIC you are using. When you select the chip MCS automatically links the correct PIC.BAS files and PIC.INC files to your code, if the correct chip is not selected you will get compile errors.
In the toolbar there are Editor and Compiler options, I think under the view button. It is there where you can choose whether to use MPASM or PM assemblers, what kind of file to output, what programmer you want to use, and a host of other goodies. Again if something does not agree with your code, then you get errors.
Additionally, if you wish to include Config Fuse settings in you code, you will need to go to the PBP Root Directiory and open the " .inc " file, in this case P16F628.inc, and comment out the default config statements there, if you do not it will throw errors at you and disregard the configs in your code.
Required reading below:
http://www.picbasic.co.uk/forum/showthread.php?t=543
http://www.picbasic.co.uk/forum/showthread.php?t=561

hu lee gan
- 17th March 2011, 15:08
Hi Joe S. - Thanks for taking the time to reply, First off here's a link to the code I'm using and the pic I'm using is a 16F1887:

http://melabs.com/resources/samples/submitted/mn1307.txt

I'm in work at the moment so won't be able to try anything until later, but thanks for the info ;)

hu lee gan
- 18th March 2011, 12:14
Right... I've read through the two threads you gave me the links to and thanks to you, it now compiles :)
But it's not working - lol - I suspect I've wired something up incorrectly as I'm getting output on the screen, but no the time & date - just zero's!
You've given me plenty of food for thought now, so I'll disappear back into the lab and report my findings ;)

Once again, thanl you for taking time out to reply - it is very apreciated.

Archangel
- 21st March 2011, 01:38
First off . . . You are Welcome, it is always a pleasure to help someone who appreciates it.

IF my Fuzzy foggy memory serves me correctly, yo need some pullup resistors on those RTC data lines . . . I THINK. Since I never actually assembled that project, I am not sure.

hu lee gan
- 25th March 2011, 15:37
Right - First off, cheers bud, your pointers have allowed me to get this up 'n running and working perfectly ;) - I owe ya a pint (or two!)
I've shelved the 16F887 and written the code to a 16F628 instead, I reckoned being a noob, it might be better to try and get my head around 'less legs' - lol and it has worked for me, I've now got a nice little RTC running on my desk and as sad as it might sound, I'm chuffed to bits with my first project.
The next thing I want to do is write some code to output the Date & Time data to RS232 when a button is pushed, but I've run out of memory on the 16F628 as Mel's code takes up pretty much all the memory that is available! I had enough space to write the code for the button monitoring... but literally didn't have enough space for the 'serout' command line - lol
Close, but no cigar...
I've ordered some 16F648's to allow me to 'port' this over seemlessly (hopefully anyway!) and will post back my findings... or failures... probably failures knowing me, but I'll get there in the end

Archangel
- 29th March 2011, 01:33
Well hu lee gan, you should be chuffed (I Think !), it feels pretty good that first working code. The great thing about the 648 is it is pin compatable with the 628 and 16f84 and there is a ton of free beginners examples for those chips, without the memory shortages you alluded to. I cut teeth on that series too, though I have grown fond of the 16F690 due largely to success I have had using it on Microchips demo boards. Too many noobs want to start out with a really complicated chip and then get frustrated and stall out before learning to walk. The really great thing about the demo boards is use of ICSP and no shakey connections, though they default to intOsc, and they do sell an 18 pin demo board. What I really like is automatic reload of hex when you compile and use PICKit2. You do not have to have demo board to use ICSP, it's just really convenient.

hu lee gan
- 29th March 2011, 14:01
Well you're spot on - I was 'attracted' to the 16F887 due to the amount of functionality it offered ( obviously didn't research enough!), but that very same flexability was where I fell down!
Having had problems configuring the fuses and then consequently reading the thread you sent me a link for (Mel's explanation of fuses etc.) I realised that I might be biting off more than I could chew and decided to move to the 'smaller' chip, and it worked for me. Once I have all of this working perfectly, I'm going to get it running on th 16F887 just to allow me to apply what I've learned thus far, on a new chip. The intention is to build what basically amounts to a box with an LCD displaying the current Date & Time which has a button under the LCD, when pressed, this outputs the current Date & Time via RS232... simples!
I've got the RTC running on one 628 and the RS232 'stuff' working on another - once the 648's arrive I should hopefully be able to combine the entire code into one program (fingers crossed!)
I haven't dabbled in electronics for many years (I'm 39 and got a C&G in digital electronics when I was 16!), and I've been meaning to play about with microcontrollers for years but never seemed to get around to it...
I'm a 2-stroke motorbike mechanic and have quite a few bike related projects 'on the go' - hopefully I'll be able to be a positive contributer to the projects section once I get my head around PB-Pro...
Thanks to this forum - the future smells of burning flux - lol

Archangel
- 29th March 2011, 16:41
You might try debugout or whatever keyword they use ( I am in the house away from My Computer ) anyway it is supposed to use less "overhead" so it might fit your 628.