Jump to content

[Version 1] [code] Psyduk


Recommended Posts

  • 3 weeks later...

You need the set the clock prescaler at the beginning of your program, if you want anything other than the default of 2 MHz. All of the C examples I've published do this. Here's the safest code:

int main(void)
{
        CPU_PRESCALE(CPU_125kHz);
        _delay_ms(1);           // allow slow power supply startup
        CPU_PRESCALE(CPU_16MHz); // set for 16 MHz clock
        //rest of your program

You can also just immediately set it to 16 MHz if you're sure the power supply comes up quickly, but this tiny delay is much safer in the most extreme case where the CPU begins running before the power is all the way up to 5 volts.

Here's some #defines you probably want to put in a header or someplace...

#define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n))
#define CPU_16MHz       0x00
#define CPU_8MHz        0x01
#define CPU_4MHz        0x02
#define CPU_2MHz        0x03
#define CPU_1MHz        0x04
#define CPU_500kHz      0x05
#define CPU_250kHz      0x06
#define CPU_125kHz      0x07
#define CPU_62kHz       0x08

Link to comment
Share on other sites

Anyone have any idea why PDOpenLinuxRunBox is failing? At least it is on the Fedora 10 systems here, I haven't tested on my Mint/Ubuntu VMs at home. Alt+F4 and Alt+F2 (tested both) aren't working, and I'm confused.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...