Çıkış tanımlı B portunun değerini bir değişkene atama...

Başlatan fbasaris, 25 Mart 2014, 18:18:13

fbasaris

Merhabalar,

int x;
set_tris_a(0x05);
x = get_tris_a();  // x = 5 olur


get_tris_a  TRISA'nın içeriğini nasıl okuyup x'e atıyorsa, bende çıkış tanımladığım B portunun değerini okumak istiyorum.

Böyle tek bir komut var mı? yoksa acaba nasıl yaparız?

Teşekkürler...

krian

 b portu bilgisi deger değişkeni olsun. deger değişkeni hesaplamak için 

b0  high yaptığın anda data[0]=1 low yaptığında data[0]=0 yap
...
..
..
b7 high yaptığında data[7]=128 low yaptığında data[7]=0 yap

son olarak port bilgisini hesaplamak için

unsigned int deger;
deger=0;
for(i=0;i<8;i++)
{
    deger=deger+data;
}




Salih

Şöyle yapabilirsin.

#byte Port_B = GETENV("SFR:PORTB")
.
.
.
x = Port_B;


Alıntı Yapinput_b()

Böyle direk okuma yapan komut var ama, sen portu çıkış olarak
ayarladığın için. Bu komutu kullandıktan sonra port tamamen giriş olarak ayarlanır.
İlgili portun adresini bu şekilde alırsan

Alıntı YapGETENV("SFR:PORTB")

Pic serisi değişince adres uyarlama ile uğraşmaktan kurtulursun.

RaMu

@salih bu çok iyiymiş
ben misal 16f877 için
(serdar çiçek hocanın kitabında ve birçok yerde gördüğüm gibi) 
#byte Port_B = 0x06
yazıyordum, ama dediğin gibi md. değiştirirsek işler yaş oluyordu,
bu yöntemi çok beğendim ve ilk defa gördüm nerden buldun bunu
hoş bana bilinmeyen birşeymiş gibi geliyorda olabilir şimdi ama
sanki pek bilinmeyen birşey, ayrıca öylemi acaba?
Sorularınıza hızlı cevap alın: http://www.picproje.org/index.php/topic,57135.0.html

SpeedyX

Arkadaşlar bu konular forumda onlarca defa konuşuldu, internette çok rahat bulunuyor. Biraz araştırın arama yapın lütfen.

rree

Bu konu daha önce geçti ama pointer ile çözmüştük. Şu Getenv bu şekilde kullanırken ilk görüyorum. Peki bu komutla 
#use delay (clock=20000000)  clock veya osilator değerini alınabilirmi?

esensoy

CCS C Help ine göz gezdirmenizi tavsiye ederim
getenv( )
Syntax:
 value = getenv (cstring);

 
 
Parameters:
 cstring is a constant string with a recognized keyword

 
 
Returns:
 A constant number, a constant string or 0

 
 
Function:
 This function obtains information about the execution environment. The following are recognized keywords.  This function returns a constant 0 if the keyword is not understood.

 

FUSE_SET:fffff
 Returns 1 if fuse fffff is enabled
 
FUSE_VALID:fffff
 Returns 1 if fuse fffff is valid
 
INT:iiiii
 Returns 1 if the interrupt iiiii is valid
 
ID
 Returns the device ID (set by #ID)
 
DEVICE
 Returns the device name string (like "PIC16C74")
 
CLOCK
 Returns the MPU FOSC
 
VERSION
 Returns the compiler version as a float
 
VERSION_STRING
 Returns the compiler version as a string
 
PROGRAM_MEMORY
 Returns the size of memory for code (in words)
 
STACK
 Returns the stack size
 
SCRATCH
 Returns the start of the compiler scratch area
 
DATA_EEPROM
 Returns the number of bytes of data EEPROM
 
EEPROM_ADDRESS
 Returns the address of the start of EEPROM. 0 if not supported by the device.
 
READ_PROGRAM
 Returns a 1 if the code memory can be read
 
ADC_CHANNELS
 Returns the number of A/D channels
 
ADC_RESOLUTION
 Returns the number of bits returned from READ_ADC()
 
ICD
 Returns a 1 if this is being compiled for a ICD
 
SPI
 Returns a 1 if the device has SPI
 
USB
 Returns a 1 if the device has USB
 
CAN
 Returns a 1 if the device has CAN
 
I2C_SLAVE
 Returns a 1 if the device has I2C slave H/W
 
I2C_MASTER
 Returns a 1 if the device has I2C master H/W
 
PSP
 Returns a 1 if the device has PSP
 
COMP
 Returns a 1 if the device has a comparator
 
VREF
 Returns a 1 if the device has a voltage reference
 
LCD
 Returns a 1 if the device has direct LCD H/W
 
UART
 Returns the number of H/W UARTs
 
AUART
 Returns 1 if the device has an ADV UART
 
CCPx
 Returns a 1 if the device has CCP number x
 
TIMERx
 Returns a 1 if the device has TIMER number x
 
FLASH_WRITE_SIZE
 Smallest number of bytes that can be written to FLASH
 
FLASH_ERASE_SIZE
 Smallest number of bytes that can be erased in FLASH
 
BYTES_PER_ADDRESS
 Returns the number of bytes at an address location
 
BITS_PER_INSTRUCTION
 Returns the size of an instruction in bits
 
RAM
 Returns the number of RAM bytes available for your device.
 
SFR:name
 Returns the address of the specified special file register. The output format can be used with the preprocessor command #bit. name must match SFR denomination of your target PIC (example: STATUS, INTCON, TXREG, RCREG, etc)
 
BIT:name
 Returns the bit address of the specified special file register bit. The output format will be in "address:bit", which can be used with the preprocessor command #byte. name must match SFR.bit denomination of your target PIC (example: C, Z, GIE, TMR0IF, etc)
 
SFR_VALID:name
 Returns TRUE if the specified special file register name is valid and exists for your target PIC (example: getenv("SFR_VALID:INTCON"))
 
BIT_VALID:name
 Returns TRUE if the specified special file register bit is valid and exists for your target PIC (example: getenv("BIT_VALID:TMR0IF"))
 
PIN:PB
 Returns 1 if PB is a valid I/O PIN (like A2)
 
UARTx_RX
 Returns UARTxPin (like PINxC7)
 
UARTx_TX
 Returns UARTxPin (like PINxC6)
 
SPIx_DI
 Returns SPIxDI Pin
 
SPIxDO
 Returns SPIxDO Pin
 
SPIxCLK
 Returns SPIxCLK Pin
 
ETHERNET
 Returns 1 if device supports Ethernet
 
QEI
 Returns 1 if device has QEI
 
DAC
 Returns 1 if device has a D/A Converter
 
DSP
 Returns 1 if device supports DSP instructions
 
DCI
 Returns 1 if device has a DCI module
 
DMA
 Returns 1 if device supports DMA
 
CRC
 Returns 1 if device has a CRC module
 
CWG
 Returns 1 if device has a CWG module
 
NCO
 Returns 1 if device has a NCO module
 
CLC
 Returns 1 if device has a CLC module
 
DSM
 Returns 1 if device has a DSM module
 
OPAMP
 Returns 1 if device has op amps
 
RTC
 Returns 1 if device has a Real Time Clock
 
CAP_SENSE
 Returns 1 if device has a CSM cap sense module and 2 if it has a CTMU module
 
EXTERNAL_MEMORY
 Returns 1 if device supports external program memory
 

 
 
Availability:
 All devices

 
 
Requires:
 Nothing

 
 
Examples:
 #IF  getenv("VERSION")<3.050

   #ERROR  Compiler version too old

#ENDIF

 

for(i=0;i<getenv("DATA_EEPROM");i++)

   write_eeprom(i,0);

 

#IF getenv("FUSE_VALID:BROWNOUT")

   #FUSE BROWNOUT

#ENDIF

  
#byte status_reg=GETENV("SFR:STATUS")

  
#bit carry_flag=GETENV("BIT:C")
 
Example Files:
 None

 
 
Also See: 
 None
En tehlikeli an "zafer" anıdır.

rree

Evet osc değerini  aldım. Kendi delay fonksiyonumu oluşturabileceğim.

#use delay(clock=4000000)
int32 Deg32A;
main kısmı
Deg32A=GETENV("CLOCK"); //isis de Deg32A değişkeninden  4000000 değerini aldığını gördüm.

RaMu

Bende yüksek clock değerlerinde karakter veya grafik lcd delayları yetersiz oluyordu
bunu düzenlemek için kullanmayı düşünüyordum, birara böyle birşey yaparım artık bu bilgiyle.
Sorularınıza hızlı cevap alın: http://www.picproje.org/index.php/topic,57135.0.html