|
µÚÒ»½Ú£º ÐÄÇéºÍʱÖÓ
˵ʵ»°ÎÒÄܹ»Ê¹Óõĵ¥Æ¬»ú²»¶à£¬ÎÒ×ÜÊÇÒÔΪÎÞÂÛʲôµ¥Æ¬»ú¶¼ÄÜ¿ª·¢³öºÃµÄ²úÆ·¡£
ǰЩÄêÓÃ51£¬×ÜÊÇÏò¸÷λ´ó´óѧϰ£¬ÎÞÐÝÖ¹µÄË÷È¡£¬ÔÚÍøÉÏ¿ñÀÀһͨ¡£ÐÄÀï¸Ð¼¤µÄͬʱҲÏë·îÏ×һЩ£¬¿ÉÊÇÎÒ»áʲô£¿ºóÀ´Ê¹ÓÃavr£¨¹«Ë¾ÒªÇ󣩻¹ÊÇÏò´ó´óÃÇѧϰ£¬ÎÒÓÖÏë·îÏ×£¬
¿ÉÊÇÎÒ»áʲô£¿ÎÒ»áµÄ´ó´óÃǶ¼Ð´ÁË£¬ÎÒ²»»áµÄ´ó´óÃÇҲдÁË¡£Ò»¸öÐÇÆÚÇ°»¨ÏîÄ¿¾·ÑÂòÁË***µÄkitÈýºÏÒ»°å£¬×î½ü¼¸ÌìÏÐÁËÏÂÀ´£¬±ã¶¯ÊÖµ÷ÊÔһϡ£ËãÊÇÓеãÐĵã¬ÎÒÓÖÏë·îÏ×£¬¿ÉÊÇÎÒ»áʲô£¿
ÎÒÖ»ÊÇÏëºÍ´ó´óÃǽ»Á÷һϣ¬ÄÄÅÂÊǶԵĻòÕßÊÇ´íµÄ£¬´ó´óÃÇÂú×ãÎÒµÄÒ»µãÐÄÔ¸°É¡£
ßë߶ÁËÕâô¶à£¬ÏÖÔÚ¿ªÊ¼°É¡£
ÅäÖ㺠stvd £¬ cosmic
ÎÒѧµ¥Æ¬»ú¿ªÃÅÈýש×ÜÊÇÒªÔҵġ£
µÚһש£º µçԴϵͳ£¬ÕâûʲôºÃ˵µÄ£¬Ö»ÊÇËüÊÇstm8¹¤×÷µÄ»ù´¡×ÜÊÇÒªÌáÒ»ÏÂ
µÚ¶þש£º ʱÖÓϵͳ£¬ÕâµÈÏÂÔÙ˵¡£
µÚÈýש£º ¸´Î»ÏµÍ³£¬stm8Ö»ÐèÒªÒ»Ö»104µçÈÝ´Óreset½Åµ½µØ¾Í¿ÉÒÔÁË¡£
ÏÖÔÚ˵˵ʱÖÓϵͳ£¬Ñ§Ï°µ¥Æ¬»úÎÞÂÛ8λµÄ»¹ÊÇ32λµÄ£¬¶¼Òª´ÓʱÖÓ¿ªÊ¼£¬ÏÂÃæÊÇÎÒÒ»¿ªÊ¼µÄʱÖÓÇл»³ÌÐò¡£
1 CLK_ECKR |=0X1; //¿ªÆôÍⲿʱÖÓ
2 while(!(CLK_ECKR&0X2)); //µÈ´ýÍⲿʱÖÓrdy
3 CLK_CKDIVR &= 0XF8; //CPUÎÞ·ÖƵ
4 CLK_SWR = 0XB4; //Ñ¡ÔñÍⲿʱÖÓ
5 CLK_SWCR |=0X2; //ʹÄÜÍⲿʱÖÓ
ÉÏÃæµÄ´úÂë¿´ÆðÀ´Ã»Ê²Ã´ÎÊÌ⣬¿ÉÔÚµ÷ÊÔ¹ý³ÌÖгöÏÖÁËÓÐʱÄÜÇл»£¬ÓÐʱÓв»ÄܵÄÇé¿ö£¬ºóÀ´·¢ÏÖÖ»ÒªÔÚµÚ5ÐÐÉèÉ϶ϵã¾ÍÄÜÇл»£¬ÎÒ¾ÍÏëÊDz»ÊǵÃÈÃcpuµÈһϣ¬ÎÒÓÖ×ÐϸµÄ·¿´ÏÂrm0016µÄʱÖÓ²¿·Ö£¬·¢ÏֵõȴýCLK_SWCRµÄ±ê־λÖÃλ²ÅÄÜÇл»¡£
¾Í±ä³ÉÁËÏÂÃæµÄ´úÂë
CLK_ECKR |=0X1; //¿ªÆôÍⲿʱÖÓ
while(!(CLK_ECKR&0X2)); //µÈ´ýÍⲿʱÖÓrdy
CLK_CKDIVR &= 0XF8; //CPUÎÞ·ÖƵ
CLK_SWR = 0XB4; //Ñ¡ÔñÍⲿʱÖÓ
while(!(CLK_SWCR&0X8)); //ÕâÀïÒªµÈ
CLK_SWCR |=0X2; //ʹÄÜÍⲿʱÖÓ
ÏÖÔÚÒ»ÇÐok£¬ÊDz»ÊǾõµÃ¿´¶«Î÷Òª×ÐϸһÏÂ~~¡£Ë³±ã˵һÏ£¬stm8ÓÐÈý¸öʱÖÓÔ´µÄ£¬hseÊÇÍⲿʱÖÓ£¬hsiÊÇÄÚ²¿16mhzµÄʱÖÓ¡£Stm8Ò»Æô¶¯Ä¬ÈÏΪÄÚ²¿Ê±ÖÓ£¬²¢ÇÒ8·ÖƵ¡£
ÆäʵÕâô´¦Àí²»ÊÇ×îºÃµÄ°ì·¨£¬Èç¹ûÍⲿʱÖÓ³öÁËÎÊÌ⣬stm8ҪɵɵµÄµÈ´ýµ½ËÀ¡£Ëü¿ÉÒÔÓÐÖжϵģ¬ÔÚÖжÏÖд¦ÀíÒ»ÇУ¬°üÀ¨»Ö¸´Ê±ÖÓÔ´£¬Õâ²ÅÊÇÕýµÀ£¬Ö»ÊÇÎұȽÏÀÁ£¬²»ÊÇ×öÕý¹æ²úÆ·£¬Ï붼²»Ô¸È¥Ïë¡£
³¤³¤µÄһƪ£¬Ã»Ê²Ã´ÄÚÈÝ£¬ÇëÔÁÂÎÒµÄßë߶°É¡£
ÓÖÏëÆðÒ»¾ä£¬×Ðϸ¿´ÊÖ²áÀïµÄʱÖÓ¸ÅÂÔͼ°É£¬Õâ¶ÔÄãÓаïÖú¡£
µÚ¶þ½Ú£ºÉµµÄ¿É°®¡ªcosmic ºÍ timeµÄÊÂÇé
ʹÓõ¥Æ¬»ú¶¨Ê±Æ÷×ÜÊÇÓõ½µÄ£¬ÎÞÂÛÊÇÑÓʱ£¬¼üÅÌɨÃ裬ÏÔʾˢУ¬»¹ÊǾÞÎްԵIJÙ×÷ϵͳ¡£Time1Ì«¹ý¸´ÔӵȹýЩÌìÔÙ˵£¬ÎÒÊÇ´Ótime2¿ªÊ¼µÄ£¬´Ó¼òµ¥µÄ¶¨Ê±¿ªÊ¼°É¡£
¼òµ¥µÄ½âÊÍһϣ¬time2ÊÇÏòÉϼÆÊýµÄ£¬²»Ïñtime1¿ÉÒÔË«Ïò¼ÆÊý£¨Õâ¶ÔÎÒºÜÓÐÓã¬ÎÒ¿ÉÒÔʹÓÃËüµÄÕý½»±àÂ빦ÄÜ£¬ÕâÕýÊÇÎÒѧstm8µÄ³õÖÔ£¬Ëü¿ÉÒÔÈÃÎÒÊ¡ÏÂһƬÕý½»¼ÆÊýÆ÷»òÊÇһƬcpld£¬µÈ¹ýÁ½Ìì´Ó¹«Ë¾½è¸ö±àÂëÆ÷£¬µ÷ÊÔһϣ©£¬ÎÒÃÇÔõô¿ÉÒÔ´ïµ½¶¨Ê±1msµÄÄ¿µÄÄÄ£¿
¹Ø¼üÊÇTIM2_ARRÕâ¸ö¼Ä´æÆ÷£¬TIM2_CNTRÊǼÆÊýµ½TIM2_ARR¾Í²úÉú¸üÐÂʼþ£¬È»ºóÇåÁã´ÓÍ·¿ªÊ¼µÄ£¬¿´ÏÂÃæµÄ´úÂë¡£
1 CLK_PCKENR1 |=0X20;//¿ªÆôʱÖÓ£¬stm8µÄÍâÉèʱÖÓ¿É¿Ø
2 TIM2_PSCR |=0X3; //DIV8 1US -> Íⲿ¾§Õñ8mhz ³ýÒÔ8ʵÏÖµ¥Î»Ê±¼äΪ1us
3 TIM2_IER |= 0X1; //ÔÊÐíÖжÏ
4 TIM2_ARR = 0X3E7; //¹Ø¼üÊÇÕâÀï
5 TIM2_CR1 |= 0X1; //¿ªÆô¶¨Ê±Æ÷
Õâ¿´ÆðÀ´Ã»´í£¬¿É¾ÍÊDz»ÄÜʵÏÖ¶¨Ê±Ð§¹û£¬ÕâÊÇΪʲô£¿´ð°¸³öºõÎÒµÄÒâÁÏ£¬¿´»ã±à´úÂëºó²Å·¢ÏÖ£¬comsicʹÓÃÁËldwÖ¸Á¶øldwÖ¸ÁîÊÇÏÈдµÍλÔÙд¸ßλµÄ¡£ARR¼Ä´æÆ÷ÊÇÒªÇóÏÈд¸ßλÔÙдµÍλµÄ£¬½«µÚ4ÐиÄΪ
TIM2_ARRH = 0X3; //
TIM2_ARRL = 0XE7;
ºó£¬ÎÊÌâ½â¾ö¡£ÓÃavrʱgcc±àÒëÆ÷¶¼¸ø×öºÃÁË£¬comsicºÜɵºÜÇ¿´ó¡£¼ÇסÕâ¸ö½Ìѵ°É£¬Òª¿´±àÒëÆ÷Êֲᣬ²»ÒªÍµÀÁ£¬¶àдһÐоͶàдһÐаɡ£Öжϲ¿·ÖÒÔºóÔÙ˵¡£¾Íµ½ÕâÀÃ÷ÌìÔÙÁÄ£¬Õâµ¢ÎóÎÒ¿´Ð¡ËµµÄʱ¼äÁË£¬°¥£¬ÎªÁËstm8ÎÒÒѾ4ÍíÉÏû¿´Ð¡ËµÁË¡£
µÚÈý½Ú£ºadµÄµ¥´Îת»»
˵ÆðadÎÒÊǾÍÍ·´ó£¬²»ÊÇ˵stm8µÄadÈÃÎÒÍ·´ó£¬¶øÊÇÒÔÇ°ÔÚ²úÆ·ÖÐʹÓõÄad
ÀÏ°å×ÜÊÇÒªÇóÔ½À´Ô½¸ß£¬´Ó16bitµ½24bit£¬´ÓÖ𽥱ƽüµ½sigma £¬ÔÚµç·ÉÏ¿Ë·þСÐźŵIJɼ¯ÊµÔÚÊÇÒ»¼þÍ´¿àµÄÊÂÇ飬ÖÁ½ñÔÚ24bitµÄ²É¼¯ÉÏÖ»Äܵ½18bitÓÐЧ룬ÓоÑéµÄÅóÓÑÒ»¶¨Òª¸æËßÎÒ¡£
ÓÖ³¶Ô¶ÁË£¬stm8Ö»ÊÇ10bitµÄad£¬Ëæ±ãÓÃÓþͿÉÒÔÁË£¬ÎÒ´ÓÀ´Ã»Ö¸ÍûËüÄܸøÎÒ³ö´óÁ¦Æø£¬µ±È»´ó´óÃÇ×öÃñÆ·£¬»òÊDZðµÄÒªÇ󲻸ߵĿÉÒÔÓÃÓá£
Ϊʲô˵µ¥´Îת»»ÄØ£¿ÒòΪ¼òµ¥£¬ÒòΪÎÒÀÁ¡£¿´ÏÂÃæµÄ´úÂë°É
//ÕâÀïÊdzõʼ»¯
CLK_PCKENR2 |=0X8; //ʹÄÜadcʱÖÓ
ADC_CSR |=0X3; //Ñ¡ÔñͨµÀ3 ½ûÖ¹ÖжÏ
ADC_CR1 |=0X71; //ʹÄÜADC£¬18·ÖƵ
ADC_CR2 |=0X8; //Êý¾ÝÓÒ¶ÔÆ룬low 8BIT AT ADC_DRL;
//ÕâÀïÊÇת»»½á¹û
unsigned int x;
unsigned int x_h;
ADC_CR1 |=0X1; //Æô¶¯×ª»»
while(!(ADC_CSR&0x80)); //µÈ´ýת»»½áÊø 14¸öʱÖÓÖÜÆÚ
ADC_CSR &= 0X7F; //Çå³ýÖжϱêÖ¾
x = ADC_DRL; //READ DATA ÒòΪÊÇÓÒ¶ÔÆëËùÒÔÏȶÁµÍλ
x_h = ADC_DRH;
x_h =( x_h << 8 ) + x;
return x_h;
Õâ´Îû³öʲô´í£¬´ó¼ÒʧÍûÁË°É£¡¹þ¹þ£¬ËµµãÌâÍâ»°£¬×ö16bitÒÔÉÏadÎÒÈÏΪҪעÒ⼸µã
1. ÓÐÒ»¸öºÃµÄ»ù×¼
2. ´«¸ÐÆ÷¹©µç×îºÃºÍ»ù×¼Áª¶¯
3. ÒªÓÐЧȥ³ý³¤Ï߸ÉÈÅ£¬Èç¼ÓÆÁ±ÎÍø£¬×öÏß×èƽºâ¡£
4. ʹÉÏÁ½¸öºÃµÄµç×è°É£¬»áÊ¡ºÜ´óÁ¦Æø
5. ²¼ÏßÒª»¨´óÁ¦Æø£¬²»ÄÜϹ²¼¡£
ÆäËüµÄ»¹Óкܶ࣬´ó´óÃǵ½ÍøÉÏ¿´°É£¬Ç°ÈËÔÔÊ÷£¬ºóÈ˳ËÁ¹¡£ÎÒÃǼ´Òª×öÇ°ÈË£¬Ò²Òª×öºóÈË¡£
µÚËĽڣºÖжÏϵͳºÍÒ»±ÈȲè
×î½üϲ»¶ºÈ²è£¬×¼±¸È¥ÂòÒ»Ìײè¾ß£¬Ò»¸öСºø£¬°Ë¸öС±ÄÇÖÖ¡£ÎÒϲ»¶Ìú¹ÛÒô£¬Å¨Å¨µÄ£¬¹öÌ̵ģ¬Ö±ÈëºíÁü¡£
ÖжϾÍÏñÒ»±Å¨Å¨µÄÌú¹ÛÒô£¬Ã»ÓвÙ×÷ϵͳµÄʱºò£¬Ê¹ÓÃÖжϰɣ¬Ò»Ñù¿ÉÒԴﵽʵʱÏìÓ¦¡£Ã»Óм«Æ·Áú¾®£¬¾ÍºÈÌú¹ÛÒô°É£¬Ò»Ñù¿Ú³ÝÁôÏã¡£
Stm8µÄÖжÏÊÇÓÐÓÅÏȼ¶µÄ£¬²»ÊÇavrÄÇÖÖ¼ÙÓÅÏȼ¶£¬ÊÇÄÇÖֵͼ¶ÖжÏÕýÔÚ´¦Àí£¬¸ß¼¶ÖжϿÉÒÔÖÕÖ¹ËüµÄÓÅÏȼ¶¡£
ÎÒÃDz»ËµÕâЩ£¬ËüÔÚ²»×öÏîĿʱ£¬ÀëÎÒ»¹ºÜÒ£Ô¶¡£
˵˵comsicµÄ¿ªÖжÏÊֶΰɿ´ÏÂÃæµÄÓï¾ä
_asm("sim"); //ÕâÊǹØÖжÏ
_asm("rim");//ÕâÊÇ¿ªÖжÏ
ÎÒ¸Õ¿ªÊ¼»¹ÒÔΪsimÊÇ¿ªÖжϣ¬½á¹û¶¨Ê±ÖжÏ×ÜÊǽø²»È¥¡£
_asm()²åÈë»ã±àÐУ¬¶àÐпÉÒÔÓÃ\n·Ö¸î
»ã±à¿é¿ÉÒÔʹÓÃÏÂÃæ¸ñʽ
#asm
//»ã±à´úÂë
#endasm
»òÕß
#pragma asm
#pragma endasm
Stvd ×Ô´øÁËÖжϴ¦ÀíÎļþ£¬ÔÚÏòÁ¿±íÀïÐÞ¸ÄÖжϺŴ¦µÄº¯ÊýÃû£¬À´ÊµÏÖÖжϷ¢Éúʱ³ÌÐòÌøµ½ÎÒÃǵÄÖжϴ¦Àí³ÌÐò¡£
ÎÒдÁËÇ°Ãæ¹ØÓÚtime2µÄ¸üÐÂÖжϡ£
ÏòÁ¿±íÖÐirq13´¦¸Ä³ÉÕâÑù {0x82, TIME2_UIS}, /* irq13 */
@far @interrupt void TIME2_UIS ( void )
{
if( ++count>temp)
{
count = 0;
PD_ODR ^=0X1; //LED·×ª
}
TIM2_SR1 &=0XFE; //Öжϱê־룬Ëü²»»á×Ô¶¯ÇåÁã
return;
}
TempÊÇÇ°Ãæadת»»µÄ½á¹û£¬ÕâÀïÀ´ÊµÏÖledµÄÉÁ˸ƵÂÊ¡£@farÊÇÖ¸³¤Ö¸Õ룬@interruptָʾÕâÊÇÒ»¸öÖжϴ¦Àíº¯Êý¡£
±¾À´»¹Ïë˵uartµÄÖжϵģ¬ÓÖÒ»ÏëÃ÷ÌìÎÒ˵uartµÄʱºò˵ɶ¡£ËùÒÔ»¹ÊÇÁôÔÚÃ÷ÌìÔÙ˵°É¡£
²èºÈµÄ¶à£¬Ë¯ÃßÖÊÁ¿ÊÜÓ°Ïì°¡¡£
µÚÎå½Ú£º ÓÀºãµÄ´®¿ÚºÍ½×¶Î¸ÐÑÔ
µÈ˵Íê´®¿Ú£¬¾ÍÒªµÈһЩÌìÔٺʹó¼Ò¼ûÃæÁË£¬º¢×Ó×ÜÊǺÍÎÒµ·ÂÒ£¬ÄÇÊÇÎҵĵÚÒ»ÉúÃü¡£
ÊÇÎÒ×æ×æ±²±²µÄÑÓÐø¡£ÇëÔÁÂÎҵĹÅÀÏ£¬ÎÒϲ»¶´«Í³µÄ£¬ÎÞÂÛÊǾ©¾ç£¬´ó¹Ä»¹ÊÇ¿ì°å¡£ËµÆðº¢×Ó£¬ÐÄÇé×ÜÊÇÓä¿ìµÄ£¬ÓÐÒ»Ì캢×Ó¸ÐðȥҽԺ£¬Ò½ÉúÒªÑéѪ£¬ÁÙ½ü»¯ÑéÊÒʱ£¬º¢×Ó¿ÞÄÖ£¬ÆÞ×ÓºåÆ˵ÊÇÆÞ×ÓÑéѪ£¬µÈ³éÍ꺢×ÓµÄѪº¢×ÓÍÛÍÛ´ó¿Þ²¢ÖÊÎÊ£º¡°ÎªÊ²Ã´Ä㻯Ñé³éÎÒµÄѪ¡±ÎÒºÍÆÞ×Ó¿àЦ¡£ÏÖÔÚÏëÀ´£¬º¢×ÓÄÇʱÌìÕæ¿É°®£¬ÏÖÔڵĺ¢×ÓٲȻһ¸±´óÈË÷áÑù£¬Ëû²Å4Ëêѽ£¬ÊÇÎÒ×öµÄ²»ºÃÂð£¿ÎÒ´ÓÀ´²»ÈÃËûÔÚ¼Ò×öºÍÍæË£Î޹صÄÊÂÇ飬°üÀ¨Ñ§Ï°¡£±ð¼ÒµÄº¢×Ӵ󶼱¨¸÷ÖÖר³¤°à£¬ÎÒ´ÓÀ´¶¼×èÖ¹ÆÞ×ÓÈ¥¸øº¢×ÓÔö¼Ó¸ºµ£¡£ÎÒÒªËûµÄͯÄê¿ì¿ìÀÖÀÖ¡£ÎÒÒªÈÃËûͯÄê³äÂúͯÕ棬¿ÉÊÇÎÒ×ö²»µ½¡£º¢×ÓÔ½À´Ô½´ÏÃ÷£¬Ô½À´Ô½³ÉÊ죬ÊÇÎÒÃÇÀÏÁËÂð£¿
ÓÖÅÜÌâÁË£¬´®¿Ú£¬×Ô´ÓÎÒ¿ªÊ¼¿ª·¢²úÆ·´ÓÀ´Ã»À뿪¹ý´®¿Ú¡£ÒòΪÎÒ×ÜÒªºÍ¼ÆËã»ú»òÆäËûµÄmcu˵»°£¬¶ø´®¿ÚÊÇ×î¼òµ¥ºÍ¾¼ÃµÄ·½Ê½¡£
´«Í³µÄÒ²ÊÇ×îÄÑÉáÆú£¬stm8µÄ´®¿Ú×ÊÔ´ºÜ·áºñ£¬¶¼ÓÐÁ½¸ö¡£ºÃЩÄêÇ°£¬ÒªÓÃË«´®¿Ú³ýÁËʹÓÃרҵоƬÍâÖ»ÄÜÑ¡Ôñ»ª°îµÄоƬ£¬ËµÊµ»°ËüÄÇʱÕæµÄºÜ¹ó¡£AvrÒ²ÓÐË«´®¿ÚµÄ£¬ËùÒÔÎÒÒ»¼ûË«´®¿ÚµÄоƬ£¬×ÜÊÇÐË·Ü¡£´ó¸ÅµÃÁË´®¿Ú¿Ö¾åÖ¢ÁË¡£
¿´´úÂ룺
CLK_PCKENR1 |= 0X08; //¿ªÆôʱÖÓ
LINUART_BRR2 = 0X1;
LINUART_BRR1 = 0X1A; //19200BPS
LINUART_CR2 = 0XAC; //8£¬n£¬1¿ªÆô·¢ËͺͽÓÊÜÖжÏ
ÉÏÃæÊdzõʼ»¯²¿·Ö£¬ºÜÊǼòµ¥×Ô¼º¿´¿´°É¡£
ÎÒ½ÓÏÂÀ´ÒªÓô®¿ÚÖжÏ×öµÄÊÂÇéºÜÎÞÁÄ£¬ÎÒҪʵÏÖÎÞÂÛ´®¿Ú½ÓÊÕµ½Ò»¸öʲôÊý¾Ý£¬¶¼Òª·µ»Ø¸ÃÊý¾Ý²¢¼Ó·¢ 0x55£¬0xaa¡£ÊµÊ±ÉÏÕâ¸öÐÒéÒ»µãÓô¦¶¼Ã»ÓУ¬ÎÒÏ£Íû´ó¼Ò¿ª·¢²úÆ·µÄʱºòÓд®¿ÚÐÒéʱ£¬Èç¹û×ÊÔ´¹»Óã¬ÓÖ²»Ô¸×Ô¼ºÐ´Ê±£¬Ê¹ÓÃmodobusÐÒé°É£¬ÕæµÄºÜºÃÓá£
ÏÂÃæÊÇÖжϳÌÐò
@far @interrupt void USART_TX( void )
{
switch( status )
{
case 0:
LINUART_DR = 0X55;
status = 1;
break;
case 1:
LINUART_DR = 0XAA;
status = 2;
break;
case 2:
LINUART_CR2 = 0X2C; //Êý¾Ý¿ÕÖжÏÖ»ÄÜдdrÇå³ý£¬ËùÒÔÖ»ÄܽûÖ¹Ëü
status = 0;
break;
}
return;
}
@far @interrupt void USART_RX(void )
{
unsigned char x;
x = LINUART_DR ; //¶ÁÊý¾Ý×Ô¶¯Çå³ýÖжϱêÖ¾
LINUART_DR = x; //ͬʱÇå³ý·¢ËÍ¿ÕÖжϱêÖ¾
LINUART_CR2 = 0XAC;//ËùÒÔ¿ÉÒÔ´ò¿ª·¢ËÍ¿ÕÖжÏÁË
status = 0;
return;
}
ͬÑùÔÚÏòÁ¿±íÖиijÉÕâÑù
{0x82, USART_TX}, /* irq20 */
{0x82, USART_RX}, /* irq21 */
ÔÚÕâ¸ö¼òµ¥µÄ»ù´¡ÉÏ£¬¾Í¿ÉÒÔ¿ª·¢×Ô¼ºµÄÐÒéÁË¡£ÎÒÓô®¿ÚֻʹÓÃÕâô¶à¹¦ÄÜ£¬±ðµÄÈçlin£¬idra£¬»òÊDZðµÄ¶¼ÊÇÒÔºóµÄÊÂÁË¡£
ºÍÐÖµÜÃÇ˵ÉùÔÙ¼û£¬Ï´ÎÔÚдʱ¾ÍÊÇÕý½»±àÂëºÍspiÁË¡£
µÚÎå½Ú£º Õý½»±àÂëºÍÒÉ»ó
½ñÌìÈ¥¹«Ë¾£¬ÕÒ±éÁË·ÏÆ·¶Ñ¶¼Ã»ÓÐÕÒµ½Ò»Ö»±àÂëÆ÷£¬Ã»°ì·¨Ö»ºÃ´Ó°ë³ÉÆ·ÉÏ ²ðÏÂÀ´Ò»¸ö£¬´ó¼Ò²»ÒªËµÊÇÎÒ×öµÄ£¬²»È»ÀÏ°å»áºÜÉúÆø¡£
Õý½»¼ÆÊý·½·¨ºÜ¶à£¬Èí¼þµÄ£¬cpldµÄ£¬Ð¾Æ¬µÄ¶¼¿ÉÒÔ£¬µ«cpuÉϼ¯³ÉÁËÎÒÃÇΪʲô²»Óã¬ÎÒûÀíÓɲ»Ñ¡´øÕý½»¹¦ÄܵÄstm8£¬ÒòΪËûÊÇ8bitµÄ£¬ÒòΪËû¼Û¸ñ¾Ý˵ºÜ±ãÒË£¬32bitµÄcpu´ó¶àÊÇ´øÕâ¸ö¹¦ÄܵİüÀ¨dsp£¬ÎÒ×ÜÊÇ˵ÔÚÎҵIJúÆ·ÀïËûÊÇ´óÂí£¬ÎҵIJúÆ·ÊÇС³µ£¬ÆäʵÊÇÎÒ²»Ô¸È¥¿Ð32bitµÄ´ó²¿Í·¡£Ð´ÍêÕâƪÎÒ϶¨¾öÐÄҪʹÓÃstm32ÁË
µ½Ê±ºòÐÖµÜÃÇÒ»¶¨Òª°ïÖúÎÒ£¬¾Íµ±ÊÇ·öƶ°É¡£
***µÄÈýºÏÒ»°åʹÓõÄоƬÊÇs207s8t6£¬44½ÅµÄ£¬time1µÄÁ½¸öÊäÈë¶ÎΪpc1£¬ºÍpc2£¬ÎÒ½«±àÂëÆ÷µÄa£¬bÏà·Ö±ð½ÓÔÚPC1,PC2ÉÏ¡£½ÓÉÏVCC ºÍ gnd £¬µç·µÄ¹¤×÷
ËãÊÇÍê³É£¬½ÓÏÂÀ´¶¼ÊÇÈí¼þµÄ¹¤×÷¡£
ÔÚ´Ë֮ǰ¿´¿´stm32µÄÕý½»±àÂë½Ó¿ÚÓ¦Óñʼǰɣ¬ÉÏÃæ¶ÔÔÀíÃèÊöµÄºÜÇå³þ£¬±ÈÎÒ˵µÄÒªÓÐÌõÀí£¬ÎҾͲ»ËµÁË¡£¿´ÏÂÃæµÄ´úÂë
//ÏÂÃæÊdzõʼ»¯²¿·Ö
CLK_PCKENR1 |=0X80; //¿ªÆôtime1ʱÖÓ
TIM1_SMCR |= 0X3; //¹¤×÷ÔÚ±àÂëÆ÷ģʽ3
TIM1_CCMR1 |= 0X1; //CC1 MAP TI1FP1 CH1
TIM1_CCMR2 |= 0X1; //CC2 MAP TI2FP2 CH2
TIM1_ARRH = 0XEA; // 60000²úÉúÒç³ö
TIM1_ARRL = 0X60;
TIM1_IER |=0X1; //¿ªÖжÏ
TIM1_CNTR = cnt_start = 30000; //ÎÒÒªÓиö´óµÄ³õʼ»¯Öµ
//ÕýºÃÊÇÂúÁ¿³ÌµÄÒ»°ë
TIM1_CR1 =0X1; //Æô¶¯¼ÆÊý
ͨ¹ýÉÏÃæ¼òµ¥µÄÅäÖã¬time1ÕýÊǹ¤×÷ÁË£¬Ðý¶¯±àÂëÆ÷£¬¿ÉÒÔ¿´µ½TIM1_CNTRµÄÊý¾Ý±ä¶¯£¬ÎÒµÄ1000Ïß±àÂëÿתһȦ²úÉú4000¸öÊý¡£
ÔÚÎÒµÄÖжϺÍÖ÷³ÌÐòÀï×öÁË´¦Àí£¬¿É¼ÆÊý·¶Î§À©Õ¹µ½32bit£¬ËãÊÇ»ù±¾´ïµ½ÁËÎÒµÄÒªÇó¡£ÓÐÒ»¼þÊÂҪ˵һÏ£¬¶ÁTIM1_CNTRʱҪÏȶÁ¸ß룬ÔÙ¶ÁµÍλ¡£
Stm8µÄ¹¤×÷¸æÒ»¶ÎÂ䣬±¾À´»¹ÒªÐ´spiµÄ£¬¿ÉÊÇ»¹Òª´îÍâΧµç·£¬µÈһЩÌì°É£¬ÎÒ°Ñad7705½ÓÉÏ£¬ÊÖÖÐÓÐÊ®¼¸Æ¬ÏÐÖõġ£
½ñÌìÎÞÒâÖÐÔÚÖжÏÀï×öÁËlongÐÍÊý¾Ý¼Ó·¨£¬±àÒëʱ¾ÓÈ»³ö´í£¬·ÁË·±àÒëÆ÷ÊֲᣬûÕÒµ½ÔÒò£¬Ï£ÍûÖªµÀµÄÅóÓѸæËßÎÒÒ»Éù¡£
ûÓÐʹÓÃÒâ·¨µÄ¿â£¬ÊÇÒòΪÎÒ¾õµÃʹÓÃËü²»ÀûÓÚÈëÃÅ£¬ËäÈ»Ëü½á¹¹ÓÅÃÀ¡£×öÏîÄ¿µÄʱºòÔÙÓðɡ£
´ÓÀ´Ã»ÕâôÈÏÕæµÄд¹ý¶«Î÷£¬ÐÄÀïºÜÊÇÊ泩¡£
ÓдíµÄµØ·½£¬ÐÖµÜÃÇÒ»¶¨Òª¸æËßÎÒ£¬²»ÒªÃÆÉù·¢´ó²Æ¡£
|
|