亿加合和智能车制作

标题: 用野火的程序得到us的PIT中断 [打印本页]

作者: 〃|竹马|、    时间: 2014-2-17 21:04
标题: 用野火的程序得到us的PIT中断
因为超声波测障碍用到的时间都是us级的,而野火里的PIT中断都是ms级的,所以我自己在底层加了一点东西来得到us的中断,但不知道是不是对的,求大神指导,希望指出哪里错了


/**************************为了得到us的PIT定时中断,加了一下东西**************************/
/**sysinit.c****/
加了:u32 bus_clk_mhz;
         bus_clk_mhz=bus_clk_khz/1000;   //不知道这里有没有什么问题bus_clk_khz是整型的,不知道可不可以直接除1000

/*****sysinit.h**/
加了:extern u32 bus_clk_mhz;


/****PIT.h****/
加了:#define     pit_init_us(PITn,us)          pit_init(PITn,us * bus_clk_mhz);         //初始化PITn,并设置定时时间(单位为 us)


作者: 〃|竹马|、    时间: 2014-2-17 21:32
编译时出了以下问题
Warning[Pa084]: pointless integer comparison, the result is always true F:\可以跑得程序\2.16 - 超声波\src\drivers\mcg\mcg.c 121
Warning[Pa084]: pointless integer comparison, the result is always true F:\可以跑得程序\2.16 - 超声波\src\drivers\mcg\mcg.c 122
Warning[Pa084]: pointless integer comparison, the result is always true F:\可以跑得程序\2.16 - 超声波\src\drivers\mcg\mcg.c 136
Warning[Pa084]: pointless integer comparison, the result is always true F:\可以跑得程序\2.16 - 超声波\src\drivers\mcg\mcg.c 137


  /* 这里提示警告,但是安全的,是为了安全才故意添加进去 */
        if     (opt <= 1 * MAX_BUS_CLK)   mcg_div.bus_div = 0;    // bus  = MCG
        else if(opt <= 2 * MAX_BUS_CLK)   mcg_div.bus_div = 1;    // bus  = MCG/2
这一行有问题       else if(opt <= 3 * MAX_BUS_CLK)   mcg_div.bus_div = 2;    // bus  = MCG/3
这一行有问题      else if(opt <= 4 * MAX_BUS_CLK)   mcg_div.bus_div = 3;    // bus  = MCG/4    这里提示警告,不过没关系

/* 这里提示警告,但是安全的,是为了安全才故意添加进去 */
        if     (opt <= 1 * MAX_FLASH_CLK)   mcg_div.flash_div = 0; // flash  = MCG
        else if(opt <= 2 * MAX_FLASH_CLK)   mcg_div.flash_div = 1; // flash  = MCG/2
        else if(opt <= 3 * MAX_FLASH_CLK)   mcg_div.flash_div = 2; // flash  = MCG/3
        else if(opt <= 4 * MAX_FLASH_CLK)   mcg_div.flash_div = 3; // flash  = MCG/4
        else if(opt <= 5 * MAX_FLASH_CLK)   mcg_div.flash_div = 4; // flash  = MCG/5
        else if(opt <= 6 * MAX_FLASH_CLK)   mcg_div.flash_div = 5; // flash  = MCG/6
        else if(opt <= 7 * MAX_FLASH_CLK)   mcg_div.flash_div = 6; // flash  = MCG/7
        else if(opt <= 8 * MAX_FLASH_CLK)   mcg_div.flash_div = 7; // flash  = MCG/8
这一行有问题        else if(opt <= 9 * MAX_FLASH_CLK)   mcg_div.flash_div = 8; // flash  = MCG/9     
这一行有问题        else if(opt <= 10 * MAX_FLASH_CLK)  mcg_div.flash_div = 9; // flash  = MCG/10
        else                              mcg_div.flash_div = 15; // flash  = MCG/16

作者: 飞思迷    时间: 2014-2-17 23:58
新版代码有us级中断的
作者: 飞思迷    时间: 2014-2-17 23:58
这些警告信息,可以不管它
作者: 〃|竹马|、    时间: 2014-2-18 12:02
飞思迷 发表于 2014-2-17 23:58
新版代码有us级中断的

可以给个新代码么,我不知道哪里找
邮箱534130404@qq.com





欢迎光临 亿加合和智能车制作 (http://www.znczz.com/) Powered by Discuz! X3.2