Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Help - my first 16F628 program

Status
Not open for further replies.

japping

New Member
I have been working on my test-kit for weeks now. The kit is functioning with at HEX-file that blink a LED every 1 second. This indicate that it is possible to comunicate and upload a program to the chip.

Next I want to write a ASM program with MPLAB IDE v7.62 from Microchip. I started with the introduction on the web-page: **broken link removed**. The time delay is added by downloading the full program at **broken link removed**.

MY full program is attached this Post.

Output from compiler is:
-----------------Output start -------------------
Clean: Deleting intermediary and output files.
Clean: Deleted file "C:\Data\Jan\Jp Engineering\Microchip\Test 07 - MPLab - blink 2\16F628TMPo_O".
Clean: Deleted file "C:\Data\Jan\Jp Engineering\Microchip\Test 07 - MPLab - blink 2\16F628TMPO.lst".
Clean: Done.
Executing: "C:\Programmer\Microchip\MPASM Suite\MPAsmWin.exe" /q /p16F628 "16F628TMPO.ASM" /l"16F628TMPO.lst" /e"16F628TMPO.err" /o"16F628TMPo_O"
Message[302] C:\DATA\JAN\JP ENGINEERING\MICROCHIP\TEST 07 - MPLAB - BLINK 2\16F628TMPO.ASM 56 : Register in operand not in bank 0. Ensure that bank bits are correct.
Message[302] C:\DATA\JAN\JP ENGINEERING\MICROCHIP\TEST 07 - MPLAB - BLINK 2\16F628TMPO.ASM 57 : Register in operand not in bank 0. Ensure that bank bits are correct.
Warning[219] C:\DATA\JAN\JP ENGINEERING\MICROCHIP\TEST 07 - MPLAB - BLINK 2\16F628TMPO.ASM 70 : Invalid RAM location specified.
Warning[219] C:\DATA\JAN\JP ENGINEERING\MICROCHIP\TEST 07 - MPLAB - BLINK 2\16F628TMPO.ASM 74 : Invalid RAM location specified.
Executing: "C:\Programmer\Microchip\MPASM Suite\MPLink.exe" "C:\Data\Jan\Jp Engineering\Microchip\Test 07 - MPLab - blink 2\16f628.lkr" "C:\Data\Jan\Jp Engineering\Microchip\Test 07 - MPLab - blink 2\16F628TMPo_O" /o"Blink.cof" /M"Blink.map" /W
MPLINK 4.13, Linker
Copyright (c) 2007 Microchip Technology Inc.
Error - section '.org_0' can not fit the absolute section. Section '.org_0' start=0x00000000, length=0x0000004e
Errors : 1

Link step failed.
BUILD FAILED: Tue Oct 23 09:09:46 2007
-----------------Output stop -------------------

I hope someone could help me ?
 

Attachments

  • 4bit.asm
    3.8 KB · Views: 225
Could it be Bank or Ram error ?

Thank you for the input, but it does not solve the problem.

Instead I have tried to comment out the delay routine as shown in the attached filen. But I still have these two messages as part of the output when compiling:
---- Message start -----
Message[302] C:\DATA\JAN\JP ENGINEERING\MICROCHIP\TEST 07 - MPLAB - BLINK 2\16F628TMPO.ASM 56 : Register in operand not in bank 0. Ensure that bank bits are correct.
Message[302] C:\DATA\JAN\JP ENGINEERING\MICROCHIP\TEST 07 - MPLAB - BLINK 2\16F628TMPO.ASM 57 : Register in operand not in bank 0. Ensure that bank bits are correct.
---- Message stop -----

I think it is one of the two following things:
1) Variabels is not defined in the right arrea
Ram EQU h'0c'
Count EQU Ram+0
timer_local EQU Ram+2
2) "ORG 0x0005" is not correct ?
3) TRISTA and TRISTB is not used the right way.
 

Attachments

  • 4bit_2.asm
    3.8 KB · Views: 165
japping said:
1) Variabels is not defined in the right arrea
Ram EQU h'0c'
Count EQU Ram+0
timer_local EQU Ram+2
Yes, General Purpose Registers start at address 0x20 in the PIC16F628.

Solution: Ram EQU h'20'
 
The problem is solved - but why ?

I have found out that changing the start of the General Purpose Registers did not have any influence on the program.

I found out that changing the Fuses from

OLD: __CONFIG _CP_OFF & _WDT_ON & _BODEN_ON & _PWRTE_ON & _ER_OSC_CLKOUT & _MCLRE_ON & _LVP_ON

to

NEW: __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _BODEN_OFF &_INTRC_OSC_NOCLKOUT & _MCLRE_ON & _LVP_OFF

helped:) . The program is now running with the attached file. The program is counting from 000 to 111 (from 0 to 4+2+1=15) on 3 LED connected to the digital output on my developmentkit.

But I don't understand what this mean ? What effect does these fuses have ? I will try to find more infromation about this.

I have attached my program to this message. Hopefully other newbee's can use it ?
 

Attachments

  • 4bit_working.txt
    3.8 KB · Views: 209
Your new file still contains the free RAM registers starting from 0Ch.Its wrong.

It must starts from 20h.

You can ignore the 302 error or place an “errorlevel -302” code in the upper part in your coding as in my first post.

Your _WDT_ON it must be _WDT_OFF
 
I'll explain the differences in your NEW config word:
_WDT_OFF
This means that the watchdog timer has been turned off. This will prevent the PIC from resetting all the time if you don't have CLRWDT in your code being executed at regular intervals.

_BODEN_OFF
This turns off the brownout detect circuit. Now the PIC won't reset when the power supply voltage drops lower than apx 4V.

_INTRC_OSC_NOCLKOUT
This makes the PIC use it's internal oscillator. Very important if you have no crystal or RC components attached.

_LVP_OFF
This turns off the low voltage programming feature. If your programmer uses high voltage programming, and most do, then this is the correct setting.
 
Thanks to all of you ....

Thanks for all your input. I have enough information now to continue my first PIC program.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top