PIC24EP512GP806 hangs some time in startup

Beta Testing discussion on mikroC PRO for PIC.
Post Reply
Author
Message
n_vikranth
Posts: 35
Joined: 11 Jan 2012 15:06

PIC24EP512GP806 hangs some time in startup

#1 Post by n_vikranth » 03 Nov 2015 10:22

system getting hangs at start up, if i change the initialize part it works but some time it gets hangs,kindly check my initialize part mentioned below and arrange the initialize part in order and also guide for required delay for all initializations.

void Init_Peripherals()
{
PLLPRE_0_bit = 0;
PLLPRE_1_bit = 0;
PLLPRE_2_bit = 0;
PLLPRE_3_bit = 0;
PLLPRE_4_bit = 0;
PLLFBD = 38; // PLL multiplier M=38
PLLPOST_0_bit = 0;
PLLPOST_1_bit = 0;


ANSELB = 0x00; // Convert all I/O pins to digital
ANSELC = 0x00;
ANSELD = 0x00;
ANSELE = 0x20;
ANSELG = 0x00;
TRISB = 0xC0C0;
TRISC = 0x00;
TRISD = 0x00;
TRISE = 0x20;
TRISF = 0x00;
TRISG = 0x00;
I2C1_Init(100000);//(121000); //Inicializar Bus I2C a 100kHz //I2C 1
PPS_Mapping_NoLock(102, _INPUT, _U1RX); // For Modbus Interfacing
PPS_Mapping_NoLock(99, _OUTPUT, _U1TX); // For Modbus Interfacing
PPS_Mapping_NoLock(96, _INPUT, _U2RX); // For USB Interfacing
PPS_Mapping_NoLock(97, _OUTPUT, _U2TX); // For USB Interfacing
PPS_Mapping(82, _OUTPUT, _SCK1OUT);
PPS_Mapping(84, _OUTPUT, _SDO1);
PPS_Mapping(83 ,_INPUT, _SDI1);
SPI1_Init_Advanced(_SPI_MASTER, _SPI_8_BIT, _SPI_PRESCALE_SEC_2, _SPI_PRESCALE_PRI_1, _SPI_SS_DISABLE, _SPI_DATA_SAMPLE_END, _SPI_CLK_IDLE_LOW, _SPI_IDLE_2_ACTIVE);
SerialFlash_init();
SerialFlash_WriteEnable(); //SPI 1
//IPC0 = IPC0 | 0x1000;
//IPC1 = IPC1 | 0x2000;
delay_ms(200);
}

void Init_Peripherals2()
{
ADC1_Init_Advanced(_ADC_12bit,_ADC_INTERNAL_REF);//ADC 1
SEL_A_Direction = 0;
SEL_B_Direction = 0;
PPS_Mapping(87, _OUTPUT, _OC1); // RG0 & RG1 as outputs
PWM_Init(5000 , 1, 1, 3); //PWM 1
PWM_Start(1);
PPS_Mapping(67, _OUTPUT, _SCK3OUT);
PPS_Mapping(65, _INPUT, _SDI3);
PPS_Mapping(66, _OUTPUT, _SDO3); // SPI configuration for Ethernet Controller
SPI3_Init_Advanced(_SPI_MASTER, _SPI_8_BIT, _SPI_PRESCALE_SEC_1, _SPI_PRESCALE_PRI_4, _SPI_SS_DISABLE, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_IDLE_2_ACTIVE);
SPI_Rd_Ptr = SPI3_Read;
SPI_Ethernet_Init(myMacAddr, myIpAddr, Spi_Ethernet_FULLDUPLEX) ;
SPI_Ethernet_confNetwork(ipMask, gwIpAddr, dnsIpAddr) ; //SPI 3
U1RXIE_bit = 1;
UART2_Init(9600); //UART 2
Modbus_init(); //UART 1
RTC_Init(); //I2C 2
InitTimer1(); //Timer 1
InitTimer2(); //Timer 2
delay_ms(50);
}

void Modbus_init()
{
/*U1MODEbits.STSEL = 0;// 1-stop bit
U1MODEbits.PDSEL = 0;// No Parity, 8-data bits
U1MODEbits.ABAUD = 0;// Auto-Baud disabled
U1MODEbits.BRGH = 1;// Standard-Speed mode */
//UART1_Init_Advanced(9600, 1, 0, 1);
UART1_Init(set_buadrate[Modbus_Data_Array[22]]);
U1STAbits.URXISEL = 0;// Interrupt after one RX character is received;
U1MODEbits.UARTEN = 1;// Enable UART
IFS0bits.U1RXIF = 0;// Clear RX Interrupt flag
IEC0bits.U1RXIE = 1; //Enable UART RX interrupt
//PC_ID=Modbus_Data_Array[21];
LATF2_bit = 0;
}

and also check image attached for configuration settings bits, i have doubt in configuration settings also.
Attachments
cofig bits.PNG
cofig bits.PNG (46.8 KiB) Viewed 4206 times

User avatar
Aleksandar.Mitrovic
mikroElektronika team
Posts: 1697
Joined: 11 Mar 2015 12:48

Re: PIC24EP512GP806 hangs some time in startup

#2 Post by Aleksandar.Mitrovic » 04 Nov 2015 14:17

Hi,

I suggest you to find initialization which is making your code to hangs.
And to go one line at the time and comment your code until example stop hanging.

Best regards,
Aleksandar

n_vikranth
Posts: 35
Joined: 11 Jan 2012 15:06

Re: PIC24EP512GP806 hangs some time in startup

#3 Post by n_vikranth » 05 Nov 2015 10:24

Thanks for reply. I tried, but cant find the issue.
My doubt is the delay time for each module initialization

User avatar
Aleksandar.Mitrovic
mikroElektronika team
Posts: 1697
Joined: 11 Mar 2015 12:48

Re: PIC24EP512GP806 hangs some time in startup

#4 Post by Aleksandar.Mitrovic » 06 Nov 2015 15:48

Hi,

Did you try to increase delay time after initialization of the modules,bigger delay which will give enough time for some modules to turn on?

Best regards,
Aleksandar

n_vikranth
Posts: 35
Joined: 11 Jan 2012 15:06

Re: PIC24EP512GP806 hangs some time in startup

#5 Post by n_vikranth » 31 Dec 2015 05:44

Increased delay timing,but facing the same problem.
I found that timer stops working,any solution.

User avatar
Aleksandar.Mitrovic
mikroElektronika team
Posts: 1697
Joined: 11 Mar 2015 12:48

Re: PIC24EP512GP806 hangs some time in startup

#6 Post by Aleksandar.Mitrovic » 06 Jan 2016 14:37

Hi,

Can you please send me your project in small zipped form I would like to see your code and settings?

Best regards,
Aleksandar

Post Reply

Return to “mikroC PRO for PIC Beta Testing”