{"action":"closed","issue":{"url":"https://api.github.com/repos/energia/msp430-lg-core/issues/10","repository_url":"https://api.github.com/repos/energia/msp430-lg-core","labels_url":"https://api.github.com/repos/energia/msp430-lg-core/issues/10/labels{/name}","comments_url":"https://api.github.com/repos/energia/msp430-lg-core/issues/10/comments","events_url":"https://api.github.com/repos/energia/msp430-lg-core/issues/10/events","html_url":"https://github.com/energia/msp430-lg-core/issues/10","id":172223535,"number":10,"title":"initClocks in MSP430's wiring.c doesn't initialize BCSCTL2 properly and double-calls enableXtal","user":{"login":"robertinant","id":1570149,"avatar_url":"https://avatars.githubusercontent.com/u/1570149?v=3","gravatar_id":"","url":"https://api.github.com/users/robertinant","html_url":"https://github.com/robertinant","followers_url":"https://api.github.com/users/robertinant/followers","following_url":"https://api.github.com/users/robertinant/following{/other_user}","gists_url":"https://api.github.com/users/robertinant/gists{/gist_id}","starred_url":"https://api.github.com/users/robertinant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robertinant/subscriptions","organizations_url":"https://api.github.com/users/robertinant/orgs","repos_url":"https://api.github.com/users/robertinant/repos","events_url":"https://api.github.com/users/robertinant/events{/privacy}","received_events_url":"https://api.github.com/users/robertinant/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/energia/msp430-lg-core/labels/IDE%20Energia","name":"IDE Energia","color":"ededed"},{"url":"https://api.github.com/repos/energia/msp430-lg-core/labels/LaunchPad%20MSP430G2...","name":"LaunchPad MSP430G2...","color":"ededed"},{"url":"https://api.github.com/repos/energia/msp430-lg-core/labels/Library%20Core","name":"Library Core","color":"ededed"},{"url":"https://api.github.com/repos/energia/msp430-lg-core/labels/Type%20Comment","name":"Type Comment","color":"ededed"}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-08-19T21:24:48Z","updated_at":"2016-08-19T21:30:38Z","closed_at":"2016-08-19T21:30:38Z","body":"_From @barawn on June 3, 2016 21:11_\n\nThe initClocks function for MSP430s based on Basic Clock Module+ (with BC2) doesn't really initialize BCSCTL2 properly. All it does in initClocks() is:\r\n``\r\n\t/* SMCLK = DCO / DIVS = nMHz */\r\n\tBCSCTL2 &= ~(DIVS_0);\r\n\tenableXtal();\r\n``\r\nIn fact, that code does nothing, because DIVS_0 is 0, so ~(DIVS_0) is 0xFF, and BCSCTL2 is an 8-bit register, so bitwise-anding it with 0xFF does nothing. I think what is desired here was actually \"BCSCTL2 &= ~(DIVS_3)\", namely, clearing all of the DIVS bits.\r\n\r\nBy the user's guide, BCSCTL2 should start up at 0, so this shouldn't be a problem, but it would be a lot more readable to explicitly replace that with\r\n\r\n``\r\n\t/* SMCLK = DCO / DIVS = nMHz */\r\n\tBCSCTL2 = SELM_0 | DIVM_0 | DIVS_0;\r\n``\r\n\r\nso that it's obvious exactly what the SMCLK and MCLK are being set to.\r\n\r\nI removed enableXtal() there because it's actually called at the end of that function anyway. enableXtal takes a *huge* amount of time if the crystal's not present, so calling it twice has a big downside.\n\n_Copied from original issue: energia/Energia#888_"}}
{"actor":{"display_login":"robertinant"}}