• AVR Freaks

Hot!PIC24FJ256GA606...

Author
Masaya Tanaka
New Member
  • Total Posts : 8
  • Reward points : 0
  • Joined: 2018/03/27 23:42:25
  • Location: 0
  • Status: offline
2019/06/20 00:41:02 (permalink)
0

PIC24FJ256GA606...

I am using "MPLAB Code Configurator" to create Project.
The code does not advance from ”while (OSCCONbits.LOCK != 1);".
 

void CLOCK_Initialize(void)
{
//Temporarily switch to FRC (without PLL), so we can safely change the PLL settings,
//in case we had previously been already running from the PLL.
__builtin_write_OSCCONH((uint8_t) (OSCCONH & 0xF8));
if(OSCCONbits.COSC != OSCCONbits.NOSC)
{
__builtin_write_OSCCONL((uint8_t) (OSCCONL & 0xFF)); //Initiate clock switching operation.
while(OSCCONbits.OSWEN != 0); //Wait for switching complete.
while (OSCCONbits.LOCK != 1); //Wait till PLL is locked
}
// CPDIV 1:1; PLLEN disabled; DOZE 1:8; RCDIV FRC; DOZEN disabled; ROI disabled;
CLKDIV = 0x3000;
// STOR disabled; STORPOL Interrupt when STOR is 1; STSIDL disabled; STLPOL Interrupt when STLOCK is 1; STLOCK disabled; STSRC SOSC; STEN disabled; TUN Center frequency;
OSCTUN = 0x00;
// ROEN disabled; ROSWEN disabled; ROSEL FOSC; ROOUT disabled; ROSIDL disabled; ROSLP disabled;
REFOCONL = 0x00;
// RODIV 0;
REFOCONH = 0x00;
// DCOTUN 0;
DCOTUN = 0x00;
// DCOFSEL 32; DCOEN disabled;
DCOCON = 0xF00;
// DIV 0;
OSCDIV = 0x00;
// TRIM 0;
OSCFDIV = 0x00;
// AD1MD enabled; T3MD enabled; T4MD enabled; T1MD enabled; U2MD enabled; T2MD enabled; U1MD enabled; SPI2MD enabled; SPI1MD enabled; T5MD enabled; I2C1MD enabled;
PMD1 = 0x00;
// OC5MD enabled; OC6MD enabled; OC7MD enabled; OC8MD enabled; OC1MD enabled; IC2MD enabled; OC2MD enabled; IC1MD enabled; OC3MD enabled; OC4MD enabled; IC6MD enabled; IC7MD enabled; IC5MD enabled; IC8MD enabled; IC4MD enabled; IC3MD enabled;
PMD2 = 0x00;
// I2C3MD enabled; PMPMD enabled; U3MD enabled; RTCCMD enabled; CMPMD enabled; CRCMD enabled; I2C2MD enabled;
PMD3 = 0x00;
// U4MD enabled; USB1MD enabled; CTMUMD enabled; REFOMD enabled; LVDMD enabled;
PMD4 = 0x00;
// IC9MD enabled; OC9MD enabled;
PMD5 = 0x00;
// SPI3MD enabled;
PMD6 = 0x00;
// DMA1MD enabled; DMA0MD enabled;
PMD7 = 0x00;
// U5MD enabled; CLC3MD enabled; CLC4MD enabled; CLC1MD enabled; CLC2MD enabled; U6MD enabled;
PMD8 = 0x00;
// CF no clock failure; NOSC FRCPLL; SOSCEN disabled; POSCEN disabled; CLKLOCK unlocked; OSWEN Switch is Complete; IOLOCK not-active;
__builtin_write_OSCCONH((uint8_t) (0x01));
__builtin_write_OSCCONL((uint8_t) (0x01));
// Wait for Clock switch to occur
while (OSCCONbits.OSWEN != 0);
while (OSCCONbits.LOCK != 1);
}

 
#1

8 Replies Related Threads

    ric
    Super Member
    • Total Posts : 22654
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: PIC24FJ256GA606... 2019/06/20 02:10:07 (permalink)
    0
    Is this on a real chip, or in the simulator?
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #2
    hkumar
    Starting Member
    • Total Posts : 16
    • Reward points : 0
    • Joined: 2012/10/03 01:12:16
    • Location: 0
    • Status: offline
    Re: PIC24FJ256GA606... 2019/06/20 03:01:32 (permalink)
    4 (1)
    Hi,
    Could you please let us know whether you have enabled the clock switching?
    Also could you please share your config(.mc3) file so that we can look into the issue.
     
    Regards,
    Harish
    #3
    Aussie Susan
    Super Member
    • Total Posts : 3583
    • Reward points : 0
    • Joined: 2008/08/18 22:20:40
    • Location: Melbourne, Australia
    • Status: offline
    Re: PIC24FJ256GA606... 2019/06/20 19:42:37 (permalink)
    0
    I don't like that write to OSCCONL as you are not actually setting the OSWEN bit.
    If this is MCC generated code then you should raise a ticket.
    Susan
    #4
    Masaya Tanaka
    New Member
    • Total Posts : 8
    • Reward points : 0
    • Joined: 2018/03/27 23:42:25
    • Location: 0
    • Status: offline
    Re: PIC24FJ256GA606... 2019/06/20 23:08:36 (permalink)
    0
    Thank you everyone.
     
    I use the MPLAB ICD3.
     
    I do not know how to share config(.mc3).
     
    I check OSWEN bit...
    #5
    hkumar
    Starting Member
    • Total Posts : 16
    • Reward points : 0
    • Joined: 2012/10/03 01:12:16
    • Location: 0
    • Status: offline
    Re: PIC24FJ256GA606... 2019/06/21 02:29:02 (permalink)
    0
    You can attach the .mc3 file here using the select button available below(while replying to the post)
    #6
    Jim Nickerson
    User 452
    • Total Posts : 6016
    • Reward points : 0
    • Joined: 2003/11/07 12:35:10
    • Location: San Diego, CA
    • Status: offline
    Re: PIC24FJ256GA606... 2019/06/21 08:16:55 (permalink)
    0
    Unless something has changed no he can not attach any files.
    10 days , 10 posts and 6 points required for new users.
    He has 10 days but only 7 posts.
    https://www.microchip.com/forums/FindPost/777101
     
    #7
    Masaya Tanaka
    New Member
    • Total Posts : 8
    • Reward points : 0
    • Joined: 2018/03/27 23:42:25
    • Location: 0
    • Status: offline
    Re: PIC24FJ256GA606... 2019/06/21 19:35:01 (permalink)
    #8
    hkumar
    Starting Member
    • Total Posts : 16
    • Reward points : 0
    • Joined: 2012/10/03 01:12:16
    • Location: 0
    • Status: offline
    Re: PIC24FJ256GA606... 2019/07/08 22:26:25 (permalink)
    0
    We tried to reproduce the issue using the config file you had shared , but issue is not reproducible. Could you please attach the project if possible.
    #9
    Jump to:
    © 2019 APG vNext Commercial Version 4.5