新手入门
- 积分
- 17
- 金钱
- 17
- 注册时间
- 2019-1-1
- 在线时间
- 2 小时
|
本帖最后由 mengguan235 于 2019-1-1 23:39 编辑
大神们 我在用Freemodbus调试时发送给主机 主机不应答!!
请问大神们什么地方出问题了!!
main函数
[mw_shl_code=c,true]#include "sys.h"
#include "delay.h"
#include "led.h"
#include "mb.h" //FreeModbus
#include "mbport.h"
#include "port.h"
/************************************************
ALIENTEK¾«ó¢STM32¿a·¢°åêμÑé1
ÅüÂíμÆêμÑé
¼¼êõÖ§3Ö£owww.openedv.com
ìÔ±|μêÆì£ohttp://eboard.taobao.com
1Ø×¢Î¢DÅ1«Öúƽì¨Î¢DÅoÅ£o"ÕyμãÔ-×ó"£¬Ãa·Ñ»ñè¡STM32×êáÏ¡£
1ãÖYêDDÇòíμç×ó¿Æ¼¼óDÏT1«Ë¾
×÷ÕߣoÕyμãÔ-×ó @ALIENTEK
************************************************/
int main(void)
{
u8 i = 0;
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
delay_init(); //Ñóê±oˉêy3õê¼»ˉ
LED_Init(); //3õê¼»ˉóëLEDᬽóμÄó2¼t½ó¿ú
eMBInit(MB_RTU, 0x0A, 1, 38400, MB_PAR_NONE); //3õê¼»ˉFreeModbus
eMBEnable(); //Æô¶ˉFreeModbus
while(1)
{
(void)eMBPoll(); //2éÑˉêy¾YÖ¡
usRegInputBuf[0]++; //2aêÔ¶áè¡êäèë¼Ä′æÆ÷óÃ
if (usRegInputBuf[0] > 250) //·àÖ13¬±ê
{
usRegInputBuf[0] = 0;
}
delay_ms(10);
i++;
if (i >= 50)
{
i = 0;
LED0 = !LED0;
}
}
}
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/
void assert_failed(uint8_t* file, uint32_t line)
{
/* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* Infinite loop */
while (1)
{
}
}
#else
void __aeabi_assert(const char * x1, const char * x2, int x3)
{
}
#endif
[/mw_shl_code]
|
-
|