Keil sayı sistemleri

Başlatan armsistem, 02 Temmuz 2011, 12:12:24

armsistem

Arkadaşlar selam , daha önce piclerle uğraşıyordum CCS ile kısa bir süre önce ARM ilgi duymaya başladım , picten daha karışık Datasheet ,registry ,sayı sistemleri vs... yaklaşık 1 aydır okuyorum, aşağıdaki bir kaç anlamadığım nokta var mesala baudrate nasıl 19200 bu şekilde yazabiliyor. Arm Wizard programından PLL hesabı vs. yapılıyor fakat bunu kağıt kalem ile nasıll yaparım.


U1LCR=0x83; // 8 bits, Parity yok, 1 Stop bit
U1DLL = 97; // 19200 Baud Rate ,
U1DLM = 0;
U1LCR = 0x03; // baudrate ayarlandi



while (!(U1LSR & 0x20)); // bus idle oluncaya kadar bekle

PLL0CFG=0x24; // MSEL = 4(multiplier =5),PSEL(PLL divider) = 2


yamak

formül şu: DLest=PCLK*(16*BR) bu formülde BR yerine istediğin baud rate i yazıyosun. sonuç küsüratlı çıkmazsa Çıkan sonucun ilk 8 bitinin değerini DLL register ına son 8 son 8 bitin değerini de DLM regiterına yazıyosun.Mesala sonuç 342 çıktı DLL registerına 86 DLM register ına 1 yazıyosun. Eğer DLest değeri küsüratlı çıkarsa istersen en yakın sayıya tamamlayıp üstekki işlemleri yaparsın ki nu iyi bi yöntem olamaz çünkü iletişimde baud rate tam istenilen gibi olmadığı için sorun çıkar.Ya da çıkan sonucu 1.5 bölersin orada çıkan sonucun da tam sayı değerini alırsın sonra FRest=PCLK*(16*BR*DLest) formülünden FRest i bulursun. Sonra datasheet "functionel divider setting look-up table" da çıkan FRest in karşısında  DivAddVal ve MulVal değerlerini bulup FDR registerına yazarsın.Örneğin en baştaki sonuç 7.5 çıktı. 7.5/1.5=5 den FRest=12MHZ*(16*115200*5)=1.3 tablodan bakıldığında DivAddVal=3 MulVal=10 olduğu görülür.Buna göre DLL=5,FDR=3<<0|10<<4; olur.Umarım anlamaşsınızdır biraz karışık oldu gibi geldi bana. :)

armsistem

Teşekkür ederim , bana iki koldan yardımcı oluyorsun mantığını anladım konu hakkında ilgili döküman bulmakta zorluk çekiyorum , iyi kötü okuduğunu anlayan birisiyim ; aşağıdaki koda bakıyorum U1LSR registers bakıyorum aşağıda düzgün import edemedim ama 0x20 ne anlama geliyor kaçlık düzeni hangi registry bakıyor


while (!(U1LSR & 0x20)); // bus idle oluncaya kadar bekle


LSR Line Status
Register
RX
FIFO
Error
TEMT THRE BI FE PE OE DR RO 0x60 U0LSR - 0xE000 C014
U2LSR - 0xE007 8014
U3LSR - 0xE007 C014

yamak

LSR saklayıcısının 5. biti 1 olduğu THR saklayıcısnın boş 0 olduğunda ise dolu olduğu anlamına geliyo. Veri gönderilirken de thr saklayıcısı boşalana kadar beklenir. oradaki 0x20 32 sayısının 16 lık tabana göre yazılışıdır.

armsistem

Teşekker ederim , hesap makinasından baktığımda dediğiniz gibi 0x20 --- 10'lık 32 sayısına eşit (windows calc) işte benim anlamadığım noktada o sayıları nereden buluyorum. İstediğim arm öğrenirken üstün körü komutları copy-paste şeklinde değil anlayarak öğrenmem. Şimdiden teşekkür ederim.

yamak

Datasheet e bakarsanız orada THR saklayıcısının 5. bitinin o işe yaradığını görürsünüz.LPC1768 in datasheet i gerçekten çok güzel hazırlanmış. Datasheete i iyice incelemenizi öneririm

armsistem

Selam , evet evet gördüm o bit ve diğerlerinin ne işe yaradığını biliyorum ama erişmek için olan sayıları nasıl hesaplıyorsunuz,Cortex M3 lpc1768 datasheeti var aşağıda 0x30 nereye denk geliyor veya 0x40 ?


Table 280: UARTn Line Status Register (U0LSR - address 0x4000 C014, U2LSR - 0x4009 8014, U3LSR - 0x4009 C014)
bit description
Bit Symbol Value Description Reset
Value
0 Receiver Data
Ready (RDR)
UnLSR0 is set when the UnRBR holds an unread character and is cleared when
the UARTn RBR FIFO is empty.
0
0 The UARTn receiver FIFO is empty.
1 The UARTn receiver FIFO is not empty.
1 Overrun Error
(OE)
The overrun error condition is set as soon as it occurs. An UnLSR read clears
UnLSR1. UnLSR1 is set when UARTn RSR has a new character assembled and
the UARTn RBR FIFO is full. In this case, the UARTn RBR FIFO will not be
overwritten and the character in the UARTn RSR will be lost.
0
0 Overrun error status is inactive.
1 Overrun error status is active.
2 Parity Error (PE) When the parity bit of a received character is in the wrong state, a parity error
occurs. An UnLSR read clears UnLSR[2]. Time of parity error detection is
dependent on UnFCR[0].
Note: A parity error is associated with the character at the top of the UARTn RBR
FIFO.
0
0 Parity error status is inactive.
1 Parity error status is active.
3 Framing Error
(FE)
When the stop bit of a received character is a logic 0, a framing error occurs. An
UnLSR read clears UnLSR[3]. The time of the framing error detection is
dependent on UnFCR0. Upon detection of a framing error, the Rx will attempt to
resynchronize to the data and assume that the bad stop bit is actually an early
start bit. However, it cannot be assumed that the next received byte will be correct
even if there is no Framing Error.
Note: A framing error is associated with the character at the top of the UARTn
RBR FIFO.
0
0 Framing error status is inactive.
1 Framing error status is active.
4 Break Interrupt
(BI)
When RXDn is held in the spacing state (all zeroes) for one full character
transmission (start, data, parity, stop), a break interrupt occurs. Once the break
condition has been detected, the receiver goes idle until RXDn goes to marking
state (all ones). An UnLSR read clears this status bit. The time of break detection
is dependent on UnFCR[0].
Note: The break interrupt is associated with the character at the top of the UARTn
RBR FIFO.
0
0 Break interrupt status is inactive.
1 Break interrupt status is active.
5 Transmitter
Holding Register
Empty (THRE))
THRE is set immediately upon detection of an empty UARTn THR and is cleared
on a UnTHR write.
1
0 UnTHR contains valid data.
1 UnTHR is empty.
6 Transmitter
Empty (TEMT)
TEMT is set when both UnTHR and UnTSR are empty; TEMT is cleared when
either the UnTSR or the UnTHR contain valid data.
1
0 UnTHR and/or the UnTSR contains valid data.
1 UnTHR and the UnTSR are empty.
UM10360 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2010. All rights reserved.
User manual Rev. 2 — 19 August 2010 308 of 840
NXP Semiconductors UM10360
Chapter 14: LPC17xx UART0/2/3
14.4.9 UARTn Scratch Pad Register (U0SCR - 0x4000 C01C, U2SCR -
0x4009 801C U3SCR - 0x4009 C01C)
The UnSCR has no effect on the UARTn operation. This register can be written and/or
read at user's discretion. There is no provision in the interrupt interface that would indicate
to the host that a read or write of the UnSCR has occurred.
14.4.10 UARTn Auto-baud Control Register (U0ACR - 0x4000 C020, U2ACR -
0x4009 8020, U3ACR - 0x4009 C020)
The UARTn Auto-baud Control Register (UnACR) controls the process of measuring the
incoming clock/data rate for the baud rate generation and can be read and written at
user's discretion.
7 Error in RX FIFO
(RXFE)
UnLSR[7] is set when a character with a Rx error such as framing error, parity
error or break interrupt, is loaded into the UnRBR. This bit is cleared when the
UnLSR register is read and there are no subsequent errors in the UARTn FIFO.
0
0 UnRBR contains no UARTn RX errors or UnFCR[0]=0.
1 UARTn RBR contains at least one UARTn RX error.
31:8 - Reserved, the value read from a reserved bit is not defined. NA
Table 280: UARTn Line Status Register (U0LSR - address 0x4000 C014, U2LSR - 0x4009 8014, U3LSR - 0x4009 C014)
bit description
Bit Symbol Value Description Reset
Value
Table 281: UARTn Scratch Pad Register (U0SCR - address 0x4000 C01C, U2SCR - 0x4009 801C, U3SCR -
0x4009 C01C) bit description
Bit Symbol Description Reset Value
7:0 Pad A readable, writable byte. 0x00
31:8 - Reserved, user software should not write ones to reserved bits. The value read from a
reserved bit is not defined.
NA
Table 282: UARTn Auto-baud Control Regis

armsistem