Hi every one
I'm using an LPC1768 core. I wrote a code for UART0 operation and used PLL to change clk frequency to 96 MHz in order to generate 115200 baudrate. the code downloaded to target successfully but i'm not able to load any program because of "Cortex-M not found ... " error. The device is not erasable whether with KEIL or SEGGER softwares. I tried Flash magic tool for erasing by serial bus but it makes an autobaud error.
Please help me to recover my chip :D thanks
And could anybody help on detecting my fault in coding that leads this problem:
#include "pconf.h" void Init_Uart0(void){ LPC_PINCON->PINSEL0= 0x5<<4; // Initializing P0.2 and P0.3 as TXD0 and RXD0 LPC_PINCON->PINMODE0=0x0<<4; // Default Pullup or Pull down LPC_PINCON->PINMODE_OD0= 00<<2; // Open drain mode disabled LPC_SC->PCLKSEL0= 01<<6; // Peripheral clock for UART0 is equal with CPU clock=96MHz LPC_UART0->LCR= 0x83; // 8-bit data, 1 stopbit, no parity, DLAB=1 to access DLL/M LPC_UART0->FDR= 0xF7; //Divaddval=7 , Mulval=15 LPC_UART0->DLL= 0x23; // BaudRate = 115200 LPC_UART0->DLM= 0; LPC_UART0->LCR= 0<<7; // DLAB=0 in order to access RBR and THR } void Send_byte(unsigned char data) { LPC_UART0->THR = data; while((LPC_UART0->LSR & 1<<5)==0); // Wait until THR becomes empty } void Send_str(unsigned char const *str) { while(1) { if ( *str == '\0') break; Send_byte(*str++); } } int main(void) { Pll_Conf(); Init_Uart0(); Send_str("Adib"); }
this header follows PLL sequence mentioned in 17xx manual
void Pll_Conf(void) { LPC_SC->PLL0CON= 0x00; LPC_SC->PLL0FEED= 0xAA; LPC_SC->PLL0FEED= PLLFEED_2; LPC_SC->CLKSRCSEL= 0x01; // Main Oscillator with frequency =12MHz selected. LPC_SC->PLL0CFG= MSEL_0<<0 | NSEL_0<<16; // Configuring multiplier and divider value LPC_SC->PLL0FEED= PLLFEED_1; LPC_SC->PLL0FEED= PLLFEED_2; LPC_SC->PLL0CON= 0x1; // Enabling PLL0 LPC_SC->PLL0FEED= PLLFEED_1; LPC_SC->PLL0FEED= PLLFEED_2; LPC_SC->CCLKCFG = PLLCLKDIV; // Cpu clk divider by 3; cclk = 96MHz while((LPC_SC->PLL0STAT & 1<<26)==0); // Wait for PLL0 to achieve lock LPC_SC->PLL0CON= 0x2; // Connect PLL0 LPC_SC->PLL0FEED= PLLFEED_1; LPC_SC->PLL0FEED= PLLFEED_2; }
1) The main oscillator is disabled on reset. I don't see you enabling it with the SCS register.
2) Peripheral Clock Selection Registers must be set before enabling and connecting PLL0, according to ES_LPC176x errata sheet.
3) When connecting to PLL0, what I do (and what the example files I've seen do) is:
LPC_SC->PLL0CON= 0x1 | 0x2;
I don't think the manual says you must set bit 0 (PLL0 Enable) while setting bit 1 (PLL0 Connect), but the register is R/W.
Thank you Jonathan for detecting my mistake, I should write 0x3 or like your command. now do you know about erasing my chip? ISP and JLINK failed to identify the core.
I have the same problem, after making change to PLL0 Configuration on system_LPC1768.c file and writing it into MCU, JLINK failed to identify the core. anybody know how to resolve the problem?
Incorrect PLL settings or a number of other oscillator-related oopses can make the JTAG interface to stop working.
That is a reason why it is recommended to make a delay loop before the code that plays with the clock settings, to make sure there is a time window for the JTAG interface to catch the processor before the incorrect code gets run.
Next option is to switch to FlashMagic using the serial ISP functionality to erase the flash. Then the JTAG interface will be available again.