AMBA
AMBA(Advanced Microprocessor Bus Architecture)是ARM公司提出的一種開放性的SoC總線標(biāo)準(zhǔn),現(xiàn)在已經(jīng)廣泛的應(yīng)用于RISC的內(nèi)核上了。?
AMBA定義了一種多總線系統(tǒng)(multilevel busing system),包括系統(tǒng)總線和等級稍低的外設(shè)總線。?
AMBA支持32位、64位、128位的數(shù)據(jù)總線,和32位的地址總線,同時支持byte和half-word設(shè)計。?
它定義了兩種總線: AHB(Advanced High-performance Bus)先進(jìn)的高性能總線,也叫做ASB(Advanced System Bus)。APB(Advanced peripheral Bus)先進(jìn)的外設(shè)總線?
AHB和ASB其實是一個東西,是高速總線,主要負(fù)責(zé)嵌入式處理器、DMA控制器、Memory等等的接口。?
APB是低速總線,主要負(fù)責(zé)外設(shè)接口?
AHB和APB之間是通過Bridge(橋接器)鏈接的?
Bus Bridges
總所周知,一個系統(tǒng)中的各個模塊之間相互通信是通過總線,總線的作用,就是把數(shù)據(jù)和地址從設(shè)備A搬運(yùn)到設(shè)備B上,?
如果說設(shè)備A和設(shè)備B具有一致性(原文是under discussion,這里我不知道怎么翻譯比較好,暫且翻譯為一致性),那么設(shè)備A和設(shè)備B可以直接掛在同一個總線上,并直接解讀總線上的數(shù)據(jù)。?
但是,如果設(shè)備A和設(shè)備B不具有一致性,那么設(shè)備A和設(shè)備B就必須掛在兩條不同的總線上,這時候我們就需要一個“翻譯”,把設(shè)備A上的總線上的數(shù)據(jù)和地址轉(zhuǎn)換成設(shè)備B可以解析的格式,然后放到設(shè)備B的總線上,這個“翻譯”就是“Bus Bridge”,?
下面這幅圖就形象的說明了Bus Bridge在AHB和APB之間的作用。?
AHB鏈接的設(shè)備的數(shù)據(jù)傳輸速度是比APB設(shè)備傳輸?shù)乃俣瓤旌芏嗟?,也就是說,這里的這個Bus Beidge所起的作用就是“緩沖”
這里可以看到AHB主要是鏈接在了系統(tǒng)的內(nèi)核以及存儲管理上面的,APB則主要分布給我外設(shè)。?
下面這張圖,更容易看出AHB和APB的作用: AHB鏈接的是系統(tǒng)總線、RAM等等 APB鏈接的是常用的外設(shè):GPIO、UART等等?
?
STM32上的總線結(jié)構(gòu)
首先看一下F103系列的芯片的總線結(jié)構(gòu)?
需要注意的是,這里有兩個APB,它們鏈接的外設(shè)是不一樣的,所以在STM32的庫文件中會有關(guān)于APB1和APB2的定義:?
?
/**?@defgroup?APB2_peripheral??
*?@{?
*/??
#define?RCC_APB2Periph_AFIO??????????????((uint32_t)0x00000001)??
#define?RCC_APB2Periph_GPIOA?????????????((uint32_t)0x00000004)??
#define?RCC_APB2Periph_GPIOB?????????????((uint32_t)0x00000008)??
#define?RCC_APB2Periph_GPIOC?????????????((uint32_t)0x00000010)??
#define?RCC_APB2Periph_GPIOD?????????????((uint32_t)0x00000020)??
#define?RCC_APB2Periph_GPIOE?????????????((uint32_t)0x00000040)??
#define?RCC_APB2Periph_GPIOF?????????????((uint32_t)0x00000080)??
#define?RCC_APB2Periph_GPIOG?????????????((uint32_t)0x00000100)??
#define?RCC_APB2Periph_ADC1??????????????((uint32_t)0x00000200)??
#define?RCC_APB2Periph_ADC2??????????????((uint32_t)0x00000400)??
#define?RCC_APB2Periph_TIM1??????????????((uint32_t)0x00000800)??
#define?RCC_APB2Periph_SPI1??????????????((uint32_t)0x00001000)??
#define?RCC_APB2Periph_TIM8??????????????((uint32_t)0x00002000)??
#define?RCC_APB2Periph_USART1????????????((uint32_t)0x00004000)??
#define?RCC_APB2Periph_ADC3??????????????((uint32_t)0x00008000)??
#define?RCC_APB2Periph_TIM15?????????????((uint32_t)0x00010000)??
#define?RCC_APB2Periph_TIM16?????????????((uint32_t)0x00020000)??
#define?RCC_APB2Periph_TIM17?????????????((uint32_t)0x00040000)??
#define?RCC_APB2Periph_TIM9??????????????((uint32_t)0x00080000)??
#define?RCC_APB2Periph_TIM10?????????????((uint32_t)0x00100000)??
#define?RCC_APB2Periph_TIM11?????????????((uint32_t)0x00200000)??
#define?IS_RCC_APB2_PERIPH(PERIPH)?((((PERIPH)?&?0xFFC00002)?==?0x00)?&&?((PERIPH)?!=?0x00))??
/**?
*?@}?
*/???
/**?@defgroup?APB1_peripheral??
*?@{?
*/??
#define?RCC_APB1Periph_TIM2??????????????((uint32_t)0x00000001)??
#define?RCC_APB1Periph_TIM3??????????????((uint32_t)0x00000002)??
#define?RCC_APB1Periph_TIM4??????????????((uint32_t)0x00000004)??
#define?RCC_APB1Periph_TIM5??????????????((uint32_t)0x00000008)??
#define?RCC_APB1Periph_TIM6??????????????((uint32_t)0x00000010)??
#define?RCC_APB1Periph_TIM7??????????????((uint32_t)0x00000020)??
#define?RCC_APB1Periph_TIM12?????????????((uint32_t)0x00000040)??
#define?RCC_APB1Periph_TIM13?????????????((uint32_t)0x00000080)??
#define?RCC_APB1Periph_TIM14?????????????((uint32_t)0x00000100)??
#define?RCC_APB1Periph_WWDG??????????????((uint32_t)0x00000800)??
#define?RCC_APB1Periph_SPI2??????????????((uint32_t)0x00004000)??
#define?RCC_APB1Periph_SPI3??????????????((uint32_t)0x00008000)??
#define?RCC_APB1Periph_USART2????????????((uint32_t)0x00020000)??
#define?RCC_APB1Periph_USART3????????????((uint32_t)0x00040000)??
#define?RCC_APB1Periph_UART4?????????????((uint32_t)0x00080000)??
#define?RCC_APB1Periph_UART5?????????????((uint32_t)0x00100000)??
#define?RCC_APB1Periph_I2C1??????????????((uint32_t)0x00200000)??
#define?RCC_APB1Periph_I2C2??????????????((uint32_t)0x00400000)??
#define?RCC_APB1Periph_USB???????????????((uint32_t)0x00800000)??
#define?RCC_APB1Periph_CAN1??????????????((uint32_t)0x02000000)??
#define?RCC_APB1Periph_CAN2??????????????((uint32_t)0x04000000)??
#define?RCC_APB1Periph_BKP???????????????((uint32_t)0x08000000)??
#define?RCC_APB1Periph_PWR???????????????((uint32_t)0x10000000)??
#define?RCC_APB1Periph_DAC???????????????((uint32_t)0x20000000)??
#define?RCC_APB1Periph_CEC???????????????((uint32_t)0x40000000)??
#define?IS_RCC_APB1_PERIPH(PERIPH)?((((PERIPH)?&?0x81013600)?==?0x00)?&&?((PERIPH)?!=?0x00))??
/**?
*?@}?
*/??
APB的速率見下面說明:?
APB1限制在了36MHz,APB2也可以達(dá)到全速72MHz?
下面是F105和F107的總線構(gòu)架:?
STM32上APB1和APB2的地址映射
評論
查看更多