我现在使用stm32跟atm91sam7x256的can无法连起来,stm32跟stm32可以连,7x256跟7x256可以连
STM32 时钟配置(8M晶振): /* HCLK = SYSCLK */ RCC_HCLKConfig(RCC_SYSCLK_Div1);
/* PCLK2 = HCLK */ RCC_PCLK2Config(RCC_HCLK_Div1);
/* PCLK1 = HCLK/2 */ RCC_PCLK1Config(RCC_HCLK_Div2);
/* PLLCLK = 8MHz * 9 = 72 MHz */ RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);
STM32 CAN速率配置(500k): CAN_InitStructure.CAN_SJW = CAN_SJW_4tq; CAN_InitStructure.CAN_BS1 = CAN_BS1_6tq; CAN_InitStructure.CAN_BS2 = CAN_BS2_6tq; CAN_InitStructure.CAN_Prescaler = 4; 7X256 时钟配置(18.432M晶振) /////////////////////////////////////////////////////////////////////////// // Init PMC Step 2. // Set PLL to 96MHz (96,109MHz) and UDP Clock to 48MHz // PLL Startup time depends on PLL RC filter: worst case is choosen // UDP Clock (48,058MHz) is compliant with the Universal Serial Bus // Specification (+/- 0.25% for full speed) /////////////////////////////////////////////////////////////////////////// AT91C_BASE_PMC->PMC_PLLR = AT91C_CKGR_USBDIV_1 | (16 << 8) | (AT91C_CKGR_MUL & (72 << 16)) | (AT91C_CKGR_DIV & 14); // Wait for PLL stabilization while( !(AT91C_BASE_PMC->PMC_SR & AT91C_PMC_LOCK) ); // Wait until the master clock is established for the case we already // turn on the PLL while( !(AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MCKRDY) );
/////////////////////////////////////////////////////////////////////////// // Init PMC Step 3. // Selection of Master Clock MCK equal to (Processor Clock PCK) PLL/2=48MHz // The PMC_MCKR register must not be programmed in a single write operation // (see. Product Errata Sheet) /////////////////////////////////////////////////////////////////////////// AT91C_BASE_PMC->PMC_MCKR = AT91C_PMC_PRES_CLK_2; // Wait until the master clock is established while( !(AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MCKRDY) );
AT91C_BASE_PMC->PMC_MCKR |= AT91C_PMC_CSS_PLL_CLK;
7X256 CAN速率配置(500k): //AT91F_CAN_CfgBaudrateReg(AT91C_BASE_CAN, 0x00053255); 上面这行是照例程中的设置,但与手册中的数据不符 AT91F_CAN_CfgBaudrateReg(AT91C_BASE_CAN, 0x00053045); 目前的问题应该是两者之间速率不匹配导致无法通信,由于没有标准的can设备,不知道哪个是正确的配置,请大家帮我看看是哪的问题,谢谢!
|