Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
LinkBack Thread Tools Display Modes
Old 15th October 2004, 06:33 PM   (permalink)
Default

Quote:
Originally Posted by sardineta
I have already compiled my asm code and this process generated a hex file of 2657 bytes.

Does this file fit in the PROGRAM MEMORY?
The hex file contains the data as ascii indormation and it also carries address information. This makes the hex file a LOT! larger then the actual code size.

if you want to know how much memory is required you should let the compiler generate a list file, it tells you how much memory is required.
You can also see it when you load the file into your programmer.

Quote:
Originally Posted by sardineta
Every variable I need, it should be initializad to zero by software?.

--------------------------
example equ 0x20
....

movlw 0x00
movwf example
--------------------------

or on power on data memory all bytes are zero.
I would like to know it because if ram is initialized to 0's on power on my code redeuce because I do not do it by software, but it still is above 2400 bytes.
It's always best to initialize any variables you use.
To make your code smaller you can use indirect adressing to clear a whole block of memory in a small loop.
Exo is offline  
Old 15th October 2004, 06:38 PM   (permalink)
Default

it should fit because 1/4 of the hex file or assembled program are zeros.. this equals 1992 14 bit bytes.. so it should fit..
williB is offline  
Old 15th October 2004, 06:45 PM   (permalink)
Default

How many zero's are in it doesn't matter
it's a intel hex file (do a google search). The data is stored as ascii wich makes it twice as large as it actually is. It also holds adress information for every 16 bytes of data wich doesn't get transferred.
Exo is offline  
Old 15th October 2004, 06:54 PM   (permalink)
Default

thanks a lot.
I will change the direct initialization mode by indirect mode
and the file size it makes feel light. (ligerito)
sardineta is offline  
Old 15th October 2004, 08:07 PM   (permalink)
Default

Quote:
Originally Posted by Exo
How many zero's are in it doesn't matter
it's a intel hex file (do a google search). The data is stored as ascii wich makes it twice as large as it actually is. It also holds adress information for every 16 bytes of data wich doesn't get transferred.
i am well aware of the extra digits in a hex file..
but i was just looking at a 70 byte hex file dos file size...and it had 66 hex digits in it plus two coln's =68 bytes plus the carrage reuurn & line feed , makes 70 bytes.. but it wasnt 132 bytes long ..go figure...

anyway i agree there are 6 bytes per line that dont get programmed into the part..counting the coln...

what i was talking about was 2 bytes of hex file data , can fit into one 14 bit program memory location...so the 2048 program memory of the 16F870 could hold a hex file at least 4096 bytes long ...
williB is offline  
Old 15th October 2004, 08:27 PM   (permalink)
Default

Thanks a lot for your comments.
I really appreciate that.

I realized that I have a ommited a register. This is the Configuration Register, some parameters can be very easy deduced but others I really do not know:

I have it in my _CONFIG

_CONFIG (MSB) NC,NC,11 0111 x011 1010 (LSB)

bit 13&12 =4&5 = 11, code protection off
bit 11 = 1, in-circuit debugger disable
bit 10 unimplemented

bit 9 WRT = 1, unprotected program memory may be written to
WHAT YOU RECOMMEND ME in bit 9

bit 8 CPD = 1 code protection OFF

bit 7 LVP = X I do not know what's in here
WHAT YOU RECOMMEND ME in bit 7

bit 6 BOREN = 0 disable
bit 3 PWRTEN = 1 disable
bit 2 WDTEN = 0 disable
bit 1 y 0 Fosc1 y 2 = 10 HS oscillator



I will use a burner called from "solaris digital" model S-103
so I think some control bits depends on it, isn't it?
what you recommend me to do with the configuration words

thanks in advanced
sardineta is offline  
Old 15th October 2004, 08:47 PM   (permalink)
Default

bit 7 LVP: Low Voltage In-Circuit Serial Programming Enable bit
1 = RB3/PGM pin has PGM function, low voltage programming enabled
0 = RB3 is digital I/O, HV on MCLR must be used for programming..
low voltage programming is with the on chip serial port .. i assume that u are using MCLR to program the part so bit 7 is a zero
williB is offline  
Old 15th October 2004, 08:57 PM   (permalink)
Default

i am pretty sure that bit 9 has to do with on chip serial programming.. also.. but i am not sure 100 % ...anyone else..??

bit 9 WRT: FLASH Program Memory Write Enable
1 = Unprotected program memory may be written to by EECON control
0 = Unprotected program memory may not be written to by EECON control
williB is offline  
Old 16th October 2004, 11:42 PM   (permalink)
Default

the correct initialization of a program should be


org 0x00
goto MAIN ;main program

org 0x04
goto ISR ;interruption service routine

MAIN ;main program begin here
blablabla

ISR ;ISR begin here
blablabla
RETFIE

END


I have seen that some people use org 0x05, does anyone know why?
I have seen it from Nigel's programs and I really do not undestand why ORG 0x00 is sometimes 0x20 for example.
is it really important, for the ISR?

I have my program finished, but when I simulate it in the MPLAB, the TMR0, is not reloaded, does I need to reload it at the end of the ISR before exit? before bcf INTCON T0IF
sardineta is offline  
Old 16th October 2004, 11:49 PM   (permalink)
Default

Quote:
Originally Posted by sardineta
I have seen that some people use org 0x05, does anyone know why?
Where have you seen that? i've never come across code wich used 0x05 as the origin for the ISR.

Quote:
Originally Posted by sardineta
I have seen it from Nigel's programs and I really do not undestand why ORG 0x00 is sometimes 0x20 for example.
Take a better look, it's the cblock that starts at 0x20 in Nigel's examples. The cblock is where variables in RAM are declared.
Exo is offline  
Old 17th October 2004, 02:24 AM   (permalink)
Default

Quote:
Originally Posted by sardineta

I have my program finished, but when I simulate it in the MPLAB, the TMR0, is not reloaded, does I need to reload it at the end of the ISR before exit? before bcf INTCON T0IF
could you post it.??
williB is offline  
Old 17th October 2004, 02:55 AM   (permalink)
Default

here is the code, well I would like to know if there is any observation that can be important to change.
For example the definitions of goto's in the ISR routine, and how about the complexity of the ISR routine, and some others at the begining of the code, like ORG 0x00, ORG 0x05, ORG 0x04

well, this code should done the following read 3dip switches at RB7,6,5
111, set a delay of 20ms
110, set a delay of 100ms
101, set a delay of 300ms
100, set a delay of 500ms
011, set a delay of 1000ms=1sec
x, don't care
x
x

RB4, define a manual mode or automatic mode, auto=1 manual=0

RB3 and 2
11 set the ADC to detect 1.25v aprox
10 set the ADC to detect 2.5v
01 set the ADC to detect 3.25v
00 x

RB0 is an external interrupt that will increment C_DF

if C_DF =>31 the system will stop to enclave

AN0 is the analog input
RA1, led system on
RA2, led TM, a TM event occurs
RA3, LED DF, a DF event occurs
RA4, turns on a relay for about 50ms to close an interruptor
RA5, turns on a relay for about 50ms to open an interruptor

TM events occurs without notice, so by polling the firmware a TM event is detected

I think that's all, see you
Attached Files
File Type: zip pic16f870.zip (4.0 KB, 15 views)
sardineta is offline  
Old 17th October 2004, 03:03 AM   (permalink)
Default

thanks ..i'm looking at it now..
williB is offline  
Old 17th October 2004, 10:02 AM   (permalink)
Default

Quote:
Originally Posted by sardineta
the correct initialization of a program should be


org 0x00
goto MAIN ;main program

org 0x04
goto ISR ;interruption service routine

MAIN ;main program begin here
blablabla

ISR ;ISR begin here
blablabla
RETFIE

END


I have seen that some people use org 0x05, does anyone know why?
In your section of code above, the address of MAIN is 0x0005 (as the address of the GOTO ISR is 0x0004 - so 0x0005 is commonly the start address of your actual code, as the reset vector at 0x0000 usually just jumps to 0x0005.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 17th October 2004, 05:08 PM   (permalink)
Default

thanks to all, so in other words it is ok, isn't it?
sardineta is offline  
Reply

Bookmarks

Thread Tools
Display Modes





All times are GMT. The time now is 03:41 PM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker