{"id":271,"date":"2012-06-25T12:08:57","date_gmt":"2012-06-25T10:08:57","guid":{"rendered":"http:\/\/www.f4ctz.fr\/?page_id=271"},"modified":"2018-11-18T18:00:54","modified_gmt":"2018-11-18T17:00:54","slug":"12f683","status":"publish","type":"page","link":"https:\/\/www.f4ctz.fr\/?page_id=271","title":{"rendered":"Microchip 12F683"},"content":{"rendered":"<p>Ceci est un exemple de code source montrant le param\u00e8trage minimal d&rsquo;un PIC12F683 pour sortir sur GPIO2 des \u00e9tats hauts d&rsquo;une longueur d&rsquo;un temps cycle soit 500ns (8MHz = 2MIPS). Cela permet ainsi de valider un circuit avec ce composant en v\u00e9rifiant que :<\/p>\n<ul>\n<li>Le composant est correctement aliment\u00e9.<\/li>\n<li>L&rsquo;oscillateur fonctionne.<\/li>\n<\/ul>\n<p>Pour cela, un fichier \u00e0 ajouter \u00e0 un projet vierge dans MPLAB avec les compilateurs Hi-Tech PICC :<\/p>\n<div id=\"wpshdo_1\" class=\"wp-synhighlighter-outer\"><div id=\"wpshdt_1\" class=\"wp-synhighlighter-expanded\"><table border=\"0\" width=\"100%\"><tr><td align=\"left\" width=\"80%\"><a name=\"#codesyntax_1\"><\/a><a id=\"wpshat_1\" class=\"wp-synhighlighter-title\" href=\"#codesyntax_1\"  onClick=\"javascript:wpsh_toggleBlock(1)\" title=\"Click to show\/hide code block\">Source code<\/a><\/td><td align=\"right\"><a href=\"#codesyntax_1\" onClick=\"javascript:wpsh_code(1)\" title=\"Show code only\"><img decoding=\"async\" border=\"0\" style=\"border: 0 none\" src=\"https:\/\/www.f4ctz.fr\/wp-content\/plugins\/wp-synhighlight\/themes\/default\/images\/code.png\" \/><\/a>&nbsp;<a href=\"#codesyntax_1\" onClick=\"javascript:wpsh_print(1)\" title=\"Print code\"><img decoding=\"async\" border=\"0\" style=\"border: 0 none\" src=\"https:\/\/www.f4ctz.fr\/wp-content\/plugins\/wp-synhighlight\/themes\/default\/images\/printer.png\" \/><\/a>&nbsp;<a href=\"https:\/\/www.f4ctz.fr\/wp-content\/plugins\/wp-synhighlight\/About.html\" target=\"_blank\" title=\"Show plugin information\"><img decoding=\"async\" border=\"0\" style=\"border: 0 none\" src=\"https:\/\/www.f4ctz.fr\/wp-content\/plugins\/wp-synhighlight\/themes\/default\/images\/info.gif\" \/><\/a>&nbsp;<\/td><\/tr><\/table><\/div><div id=\"wpshdi_1\" class=\"wp-synhighlighter-inner\" style=\"display: block;\"><div class=\"c\" style=\"font-family:monospace;\"><span class=\"co2\">#include &lt;htc.h&gt;<\/span><br \/>\n<br \/>\n<span class=\"co1\">\/\/\/\/\/\/\/\/\/\/\/ Bits de configuration : Voir datasheet page 84, 12.1 Configuration bits \/\/\/\/\/\/\/\/\/\/\/\/\/\/<\/span><br \/>\n__CONFIG<span class=\"br0\">&#40;<\/span>FCMEN_OFF \\<br \/>\n&nbsp; &nbsp; <span class=\"sy0\">&amp;<\/span> IESO_OFF \\<br \/>\n&nbsp; &nbsp; <span class=\"sy0\">&amp;<\/span> BOREN_OFF \\<br \/>\n&nbsp; &nbsp; <span class=\"sy0\">&amp;<\/span> CPD_OFF \\<br \/>\n&nbsp; &nbsp; <span class=\"sy0\">&amp;<\/span> CP_OFF \\<br \/>\n&nbsp; &nbsp; <span class=\"sy0\">&amp;<\/span> MCLRE_ON \\<br \/>\n&nbsp; &nbsp; <span class=\"sy0\">&amp;<\/span> PWRTE_ON \\<br \/>\n&nbsp; &nbsp; <span class=\"sy0\">&amp;<\/span> WDTE_OFF \\<br \/>\n&nbsp; &nbsp; <span class=\"sy0\">&amp;<\/span> FOSC_INTOSCIO<span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n<br \/>\n<span class=\"kw4\">void<\/span> main<span class=\"br0\">&#40;<\/span><span class=\"kw4\">void<\/span><span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n<span class=\"co1\">\/\/\/\/ Configuration de l'oscillateur interne (datasheet page 20, 3.2 Oscillator control) \/\/\/\/\/\/\/\/\/\/<\/span><br \/>\n&nbsp; &nbsp; OSCCONbits.<span class=\"me1\">IRCF<\/span> <span class=\"sy0\">=<\/span> <span class=\"nu6\">0b111<\/span><span class=\"sy0\">;<\/span>&nbsp; &nbsp; <span class=\"co1\">\/\/ 8Mhz<\/span><br \/>\n&nbsp; &nbsp; OSCCONbits.<span class=\"me1\">SCS<\/span> <span class=\"sy0\">=<\/span> <span class=\"nu0\">0<\/span><span class=\"sy0\">;<\/span> &nbsp; &nbsp; <span class=\"co1\">\/\/ Configuration de l'horloge systeme<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"co1\">\/\/ d\u00e9finie par les bits de configuration<\/span><br \/>\n<br \/>\n<span class=\"co1\">\/\/\/\/\/ Configuration de entrees\/sorties numeriques \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/<\/span><br \/>\n&nbsp; &nbsp; ANSELbits.<span class=\"me1\">ANS2<\/span> <span class=\"sy0\">=<\/span> <span class=\"nu0\">0<\/span><span class=\"sy0\">;<\/span> &nbsp; &nbsp; <span class=\"co1\">\/\/ GPIO2 est numerique<\/span><br \/>\n&nbsp; &nbsp; TRISIObits.<span class=\"me1\">TRISIO2<\/span> <span class=\"sy0\">=<\/span> <span class=\"nu0\">0<\/span><span class=\"sy0\">;<\/span> &nbsp; &nbsp; <span class=\"co1\">\/\/ GPIO2 est une sortie<\/span><br \/>\n<br \/>\n&nbsp; &nbsp; <span class=\"kw1\">while<\/span><span class=\"br0\">&#40;<\/span>1<span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; GPIObits.<span class=\"me1\">GP2<\/span> <span class=\"sy0\">=<\/span> <span class=\"nu0\">1<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; GPIObits.<span class=\"me1\">GP2<\/span> <span class=\"sy0\">=<\/span> <span class=\"nu0\">0<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><\/div><\/div><\/div><\/p>","protected":false},"excerpt":{"rendered":"<p>Ceci est un exemple de code source montrant le param\u00e8trage minimal d&rsquo;un PIC12F683 pour sortir sur GPIO2 des \u00e9tats hauts d&rsquo;une longueur d&rsquo;un temps cycle soit 500ns (8MHz = 2MIPS). Cela permet ainsi de valider un circuit avec ce composant en v\u00e9rifiant que : Le composant est correctement aliment\u00e9. L&rsquo;oscillateur fonctionne. Pour cela, un fichier [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":267,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[],"tags":[169,148,134,133,139,150],"class_list":["post-271","page","type-page","status-publish","hentry","tag-blinking","tag-code-source","tag-microchip","tag-microcontroleur","tag-pic12f","tag-pic12f683"],"_links":{"self":[{"href":"https:\/\/www.f4ctz.fr\/index.php?rest_route=\/wp\/v2\/pages\/271","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.f4ctz.fr\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.f4ctz.fr\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.f4ctz.fr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.f4ctz.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=271"}],"version-history":[{"count":0,"href":"https:\/\/www.f4ctz.fr\/index.php?rest_route=\/wp\/v2\/pages\/271\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/www.f4ctz.fr\/index.php?rest_route=\/wp\/v2\/pages\/267"}],"wp:attachment":[{"href":"https:\/\/www.f4ctz.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=271"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.f4ctz.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=271"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.f4ctz.fr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=271"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}