Hello everyone,
I am trying to use the following peripherals in my application: UART0, SPI0, I2C0 and RTC
For some reason when I enable the interruption of the serial port the other peripherals do not work correctly:Confirm that the initialization and enablement of all peripherals are correct:
void uart_init(void) //9600 BAUD pclock 48MHZ { PINSEL0 |=0x00000005; //U0FCR=0x07; //enable FIFO U0LCR=0X83; //8-data bits, 1 Stop bit, Disable Parity and Enable DLAB U0DLL=0x38; // MULVAL = 0x5 and DIVADDVAL = 14 U0DLM=1; //U0FDR= 0x00000010; // MULVAL = 1 and DIVADDVAL = 0 U0LCR=0X03; //cleared DLAB U0IER= 0x00000001; //Interrupt } void UART0_Interrupt_EN(void) { VICIntSelect = 0x00000000; VICVectAddr6 = (unsigned) UART0Handler; //Vector VICVectCntl6 = 0x00000020 | 6; //select UART0 interrupt as IRQ i.e vector 6 VICIntEnable |=(1UL<<6); } //----------------------------------------------------------------- void init_RTC(char *time) { //PREINT = (int)(PCLK/32768)-1 //PREFRAC = PCLK - ((PREINT+1)*32768 PCONP = (PCONP | (1<<9)); /* PCRTC = 1 */ PREINT = 0x5B7; PREFRAC = 0x6c00; CIIR = 0x03; /* Minutes value increment interrupt */ CCR = 0x1; //Start the RTC //ILR = 0x01; /* RTC interrupts enabled */ } void RTC_Interrupt_EN(void) { VICIntSelect = 0x00000000; VICVectAddr13 = (unsigned) read_rtc; //Vector VICVectCntl13 = (1UL<<5) | 13; //select RTC interrupt as IRQ i.e vector 13 VICIntEnable |=(1UL<<13); } //----------------------------------------------------------------- void I2C_Init (void) //pclock 48MHZ { // Power on I2C0 peripheral PCONP |= 0x00000080; // Define port pin as SDA and SCL PINSEL0 |= 0x00000050 ; I2C0CONCLR = 0x6C; // clear all I2C config bits I2C0CONSET = 0x40; // set I2EN // I2C Clock Duty Cycle (high and low) I2C0SCLH = PERIFERAL_OPERATING_FREQUENCY_IN_HZ/(2*EEPROM_OPERATING_FREQUENCY_IN_HZ); I2C0SCLL = PERIFERAL_OPERATING_FREQUENCY_IN_HZ/(2*EEPROM_OPERATING_FREQUENCY_IN_HZ); } //---------------------------------------------------------------- void SPI_init(void) { PINSEL0 |=0x1500; S0SPCCR=0x8; //pclock 48MHZ ---> 48khz S0SPCR=0x0824; //Master }
1. with MDK 5 in use install the corresponding Legacy Pack for Arm7 (as you use a LPC2136):
http://www.keil.com/support/docs/4184.htm
2. See: Demonstration of
"Retarget Input and Output via UART" at:
https://www.keil.com/pack/doc/compiler/RetargetIO/html/_retarget__examples__u_a_r_t.html
rtoribio said:I am trying to use the following peripherals in my application: UART0, SPI0, I2C0 and RTC
Note that the peripherals are entirely proprietary to the chip maker - they have nothing to do with ARM.
Therefore, the people to ask for specific help with using peripherals is the chip maker - in this case, NXP.
https://community.arm.com/developer/tools-software/tools/f/keil-forum/43684/lpc2148-timer0-not-working-as-expected/158950#158950
Have you checked NXP's website for documentation, application notes, examples, etc ... ?
https://www.nxp.com/products/processors-and-microcontrollers/arm-microcontrollers/general-purpose-mcus/lpc2000-arm7:MC_71580#/
Also note that these are rather old parts:
https://community.nxp.com/thread/471178
https://community.arm.com/developer/tools-software/tools/f/keil-forum/43684/lpc2148-timer0-not-working-as-expected/158933#158933
So, if you're just starting out, why not start with something current ?