Occur Default handler when start Init Uart

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Occur Default handler when start Init Uart

595 Views
noahkwon
Contributor I

hi, guys. I'm begginer in freescale.

 

actually, I didn't even know that what the problem is in this code.

I think that is default handler.

 

when I was coding for uart driver I got a problem about default handler.

 

Maybe I know that picture of bottom is occured exception and next bottom is main code.

 

I already got many solutions for this issue on this community. but, I couldn't do that

 

I guess that issue is related Clock Gating.. whatever

 

this board is FRDM-K64F

 

nobody know that issue... TT so, if anybody know that problem.... help me...

 

thank you.

 

Noah.

 

51796_51796.pngdefault handler_1.png

 

------------------------------------------------------------------------------------------------------------------------------------------------

#include "Cpu.h"
#include "Events.h"
#include "clockMan1.h"
#include "pin_init.h"
#include "osa1.h"

#include "Drv_UART.h"
#if CPU_INIT_CONFIG
  #include "Init_Config.h"
#endif

#define REG_RW(x) (volatile uint32_t *)(x)

 

int main(void)
{
      PE_low_level_init();

     Init_Uart(4,50000000,115200);

 

     #ifdef PEX_RTOS_START
      PEX_RTOS_START();
      #endif

     for(;;){}

}

 

void Init_Uart(char ch ,int SysClk, int Baud)
{


      int mReg,ubd;

     *REG_RW(SIM_SCGC1) |= 0x1 << 10;                                               // Enable the clock to the selected UART

 

     mReg = *REG_RW(UART4_C2);                                                          // Tx, Rx are disabled
      mReg = (mReg & ~(0x1 << 2)) | (0x0 << 2);
      mReg = (mReg & ~(0x1 << 3)) | (0x0 << 3);
      *REG_RW(UART4_C2) = mReg;

 

     *REG_RW(UART4_C1) = 0;                                                                 // all default settings

 

     ubd = (uint32_t)((SysClk)/(Baud*16));                                                   // Calculate Baud Settings

 

     mReg = *REG_RW(UART4_BDH);
      *REG_RW(UART4_BDH) = (mReg & ~(0x1F << 0)) | (ubd >> 8);       // BDH
      *REG_RW(UART4_BDL) = (uint8_t)(ubd & 0xff);                                // BDL

 

     mReg = *REG_RW(UART4_C4);                                                        // BRFA
      mReg = (mReg & ~(0x1F << 0)) | (0x1 << 2);
      *REG_RW(UART4_C4) = mReg;

 

     mReg = *REG_RW(UART4_C2);                                                         // Tx, Rx are enabled
      mReg = (mReg & ~(0x1 << 2)) | (0x1 << 2);
      mReg = (mReg & ~(0x1 << 3)) | (0x1 << 3);
      *REG_RW(UART4_C2) = mReg;

 

     mReg = *REG_RW(UART4_S2);                                                           // Most Significant Bit First
      mReg = (mReg & ~(0x1 << 5)) | (0x0 << 0);
      *REG_RW(UART4_S2) = mReg;
}

------------------------------------------------------------------------------------------------------------------------------------------------

Labels (1)
1 Reply

382 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello noah,

(1) Form your picture , i see you use KDS and  KSDK,  please tell me the version of KDS and SDK .

(2) IN you code, i see when initialize the UART component , you sue the code by yourself , and in the KSDK driver , there have

UART_DRV_Init , you can directly use , and under the SDK install directory , there are some UART demo , you can refer to :

...Freescale\KSDK_1.2.0\examples\frdmk64f\driver_examples\uart

(3) Also you can use the Processor Expert , directly add UART component , then configure , then it can generate code

pastedImage_0.png

(4) If you still want to know why is wrong about your code , please send your project to me , i will test it on my side .

Hope it helps


Have a great day,
Alice

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos