allocating a varable as a bit rather than a byte save memory space in the pic ??? , i have several varables which required as flags only !!!
allocating a varable as a bit rather than a byte save memory space in the pic ??? , i have several varables which required as flags only !!!
From the manual....
When BIT variables are created, PBP must reserve full BYTEs of RAM and then
assign variable names to each bit within the BYTE containers. This is fine in most
cases, but you may wish to control this yourself. To create a bit variable and
control the BYTE it's assigned to, you can use aliasing to do it manually:
my_flags VAR BYTE 'Create a container for bits
flag0 VAR my_flags.0 'Assign an alias to bit-0
flag1 VAR my_flags.1 'Assign an alias to bit-1
This is exactly what PBP would do in the background, but it will assign its own
name to the "container" BYTE variable. It's useful to take control and assign this
name manually, especially when debugging in an environment that won't show
individual bits in a watch window.
Dave
Always wear safety glasses while programming.
Just like that mackrackit!!
I, for example, in a project to implement a 10-bit ADC and the output of the pic, I had to generate a 10-bit DAC to simulate approximately the incoming analog signal, so I wrote this (similar to the example):
Adc VAR WORD
D0 VAR Adc.0
D1 VAR Adc.1
D2 VAR Adc.2
D3 VAR Adc.3
D4 VAR Adc.4
D5 VAR Adc.5
D6 VAR Adc.6
D7 VAR Adc.7
D8 VAR Adc.8
D9 VAR Adc.9
TRISA = %11111111
TRISB = %00000000
TRISD = %00000000
ADCON1.7 = 1
Inicio:
ADCIN 0,Adc
PORTD.0 = D0
PORTD.1 = D1
PORTD.2 = D2
PORTD.3 = D3
PORTD.4 = D4
PORTD.5 = D5
PORTD.6 = D6
PORTD.7 = D7
PORTB.0 = D8
PORTB.1 = D9
GoTo Inicio
regards friends!!!
Last edited by martintorres; - 15th September 2012 at 09:04.
OrOr perhaps evenCode:PortD = ADC.LowByte ' Or ADC.Byte0 PortB.0 = ADC.8 PortB.1 = ADC.9But the later will write "fill" the upper 6 bits of PortB with zeros (or whatever is in the upper 6 bits of the ADC variable) which may or may not be an actual problem.Code:PortD= ADC.LowByte PortB = ADC.HighByte
Neither of this has anything to do with the original question of course, sorry about that.
/Henrik.
One from the Queen
http://www.picbasic.co.uk/forum/showthread.php?t=544
Dave
Always wear safety glasses while programming.
Bookmarks