新手入门
积分 10
金钱 10
注册时间 2021-4-9
在线时间 1 小时
1 金钱
我用正点原子的电机的控制方案,1、电机正转,上电起始的霍尔信号(ha hb hc)为5和4是不转动的,如果起始状态在其他霍尔信号的状态就可以转动。
电机反转转,上电起始的霍尔信号(ha hb hc)为2和3是不转动的,如果起始状态在其他霍尔信号的状态就可以转动。这是用库函数写的。
2、我又用正点原子的DM407的hal库程序移植到自己的电机控制方案中,发现还是一样的问题,电机正传直接卡在霍尔信号(ha hb hc)4这个状态,反转卡在霍尔信号(ha hb hc)为2这个状态。
电机的硬件控制方案应该没问题,用cpld控制是没问题的,用32单片机控制就有点问题。
疑问:为什么用cpld控制电机没问题,用32单片机就有问题,是不是单片机程序的问题,6步相序是没问题的用cpld试验过。但是32单片机的hal库程序是移植正点原子的,按理说不应该有错。
库函数
void TIM5_IRQHandler(void)
{
GPIO_SetBits(GPIOC,GPIO_Pin_13);
g_bldc_motor1.step_sta = hallsensor_get_state();
if(TIM_GetITStatus(TIM5,TIM_IT_Update)==SET)
{
if( g_bldc_motor1.step_sta==0x00|| g_bldc_motor1.step_sta==7)
{
GPIO_ResetBits(GPIOC,GPIO_Pin_13);
}
if(g_bldc_motor1.run_flag == 1)
{
//正传
// switch(g_bldc_motor1.step_sta)
// {
// case 0x01: m1_blch() ;break;
// case 0x02: m1_albh() ;break;
// case 0x03: m1_alch() ;break;
// case 0x04: m1_ahcl() ;break;
// case 0x05: m1_ahbl() ;break;
// case 0x06: m1_bhcl() ;break;
// default : break;
// }
//反转
switch(g_bldc_motor1.step_sta)
{
case 0x01: m2_bhcl() ;break;
case 0x02: m2_ahbl() ;break;
case 0x03: m2_ahcl() ;break;
case 0x04: m2_alch() ;break;
case 0x05: m2_albh() ;break;
case 0x06: m2_blch() ;break;
default : break;
}
}
}
TIM_ClearITPendingBit(TIM5,TIM_IT_Update);
}
halku的中断函数
/**
****************************************************************************************************
* @file bldc_tim.c
* @Author ÕýµãÔ­×ÓÍŶÓ(ALIENTEK)
* @version V1.0
* @date 2021-10-19
* @brief ¶¨Ê±Æ÷ Çý¶¯´úÂë
* @license Copyright (c) 2020-2032, ¹ãÖÝÊÐÐÇÒíµç×ӿƼ¼ÓÐÏÞ¹«Ë¾
****************************************************************************************************
* @attention
*
* ʵÑéƽ̨:ÕýµãÔ­×Ó F407µç»ú¿ª·¢°å
* ÔÚÏßÊÓƵ:www.yuanzige.com
* ¼¼ÊõÂÛ̳:www.openedv.com
* ¹«Ë¾ÍøÖ·:www.alientek.com
* ¹ºÂòµØÖ· penedv.taobao.com
*
* ÐÞ¸Ä˵Ã÷
* V1.0 20211019
* µÚÒ»´Î·¢²¼
*
****************************************************************************************************
*/
#include "./BSP/TIMER/bldc_tim.h"
#include "./BSP/LED/led.h"
#include "./BSP/BLDC/bldc.h"
/******************************************************************************************/
/* ¶¨Ê±Æ÷ÅäÖþä±ú ¶¨Òå */
/* ¸ß¼¶¶¨Ê±Æ÷PWM */
TIM_HandleTypeDef g_atimx_handle; /* ¶¨Ê±Æ÷x¾ä±ú */
TIM_OC_InitTypeDef g_atimx_oc_chy_handle; /* ¶¨Ê±Æ÷Êä³ö¾ä±ú */
extern _bldc_obj g_bldc_motor1;
/******************************************************************************************/
/**
* @brief ¸ß¼¶¶¨Ê±Æ÷TIMX PWMÊä³ö³õʼ»¯º¯Êý
* @note
* ¸ß¼¶¶¨Ê±Æ÷µÄʱÖÓÀ´×ÔAPB2, ¶ø CLK2 = 168Mhz, ÎÒÃÇÉèÖà PRE2²»·ÖƵ, Òò´Ë
* ¸ß¼¶¶¨Ê±Æ÷ʱÖÓ = 168Mhz
* ¶¨Ê±Æ÷Òç³öʱ¼ä¼ÆËã·½·¨: Tout = ((arr + 1) * (psc + 1)) / Ft us.
* Ft=¶¨Ê±Æ÷¹¤×÷ƵÂÊ,µ¥Î»:Mhz
*
* @param arr: ×Ô¶¯ÖØ×°Öµ
* @param psc: ʱÖÓÔ¤·ÖƵÊý
* @retval ÎÞ
*/
void atim_timx_oc_chy_init(uint16_t arr, uint16_t psc)
{
ATIM_TIMX_PWM_CHY_CLK_ENABLE(); /* TIMX ʱÖÓʹÄÜ */
g_atimx_handle.Instance = ATIM_TIMX_PWM; /* ¶¨Ê±Æ÷x */
g_atimx_handle.Init.Prescaler = psc; /* ¶¨Ê±Æ÷·ÖƵ */
g_atimx_handle.Init.CounterMode = TIM_COUNTERMODE_UP; /* ÏòÉϼÆÊýģʽ */
g_atimx_handle.Init.Period = arr; /* ×Ô¶¯ÖØ×°ÔØÖµ */
g_atimx_handle.Init.ClockDivision=TIM_CLOCKDIVISION_DIV1; /* ·ÖƵÒò×Ó */
// g_atimx_handle.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; /*ʹÄÜTIMx_ARR½øÐлº³å*/
// g_atimx_handle.Init.RepetitionCounter = 0; /* ¿ªÊ¼Ê±²»¼ÆÊý*/
HAL_TIM_PWM_Init(&g_atimx_handle); /* ³õʼ»¯ WM */
g_atimx_oc_chy_handle.OCMode = TIM_OCMODE_PWM1; /* ģʽѡÔñ WM1 */
g_atimx_oc_chy_handle.Pulse = 0;
g_atimx_oc_chy_handle.OCPolarity = TIM_OCPOLARITY_HIGH; /* Êä³ö±È½Ï¼«ÐÔΪ¸ß */
// g_atimx_oc_chy_handle.OCNPolarity = TIM_OCNPOLARITY_HIGH;
// g_atimx_oc_chy_handle.OCFastMode = TIM_OCFAST_DISABLE;
// g_atimx_oc_chy_handle.OCIdleState = TIM_OCIDLESTATE_RESET;
// g_atimx_oc_chy_handle.OCNIdleState = TIM_OCNIDLESTATE_RESET;
HAL_TIM_PWM_ConfigChannel(&g_atimx_handle, &g_atimx_oc_chy_handle, ATIM_TIMX_PWM_CH1); /* ÅäÖÃTIMxͨµÀy */
HAL_TIM_PWM_ConfigChannel(&g_atimx_handle, &g_atimx_oc_chy_handle, ATIM_TIMX_PWM_CH2); /* ÅäÖÃTIMxͨµÀy */
HAL_TIM_PWM_ConfigChannel(&g_atimx_handle, &g_atimx_oc_chy_handle, ATIM_TIMX_PWM_CH3); /* ÅäÖÃTIMxͨµÀy */
/* ¿ªÆô¶¨Ê±Æ÷ͨµÀ1Êä³ö WM */
HAL_TIM_PWM_Start(&g_atimx_handle,TIM_CHANNEL_2);
/* ¿ªÆô¶¨Ê±Æ÷ͨµÀ2Êä³ö WM */
HAL_TIM_PWM_Start(&g_atimx_handle,TIM_CHANNEL_3);
/* ¿ªÆô¶¨Ê±Æ÷ͨµÀ3Êä³ö WM */
HAL_TIM_PWM_Start(&g_atimx_handle,TIM_CHANNEL_4);
}
/**
* @brief ¶¨Ê±Æ÷µ×²ãÇý¶¯£¬Ê±ÖÓʹÄÜ£¬Òý½ÅÅäÖÃ
´Ëº¯Êý»á±»HAL_TIM_PWM_Init()µ÷ÓÃ
* @param htim:¶¨Ê±Æ÷¾ä±ú
* @retval ÎÞ
*/
void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef *htim)
{
if (htim->Instance == ATIM_TIMX_PWM)
{
GPIO_InitTypeDef gpio_init_struct;
ATIM_TIMX_PWM_CHY_CLK_ENABLE(); /* ¶¨Ê±Æ÷ʱÖÓʹÄÜ */
/* ÉÏÇű۵ÄIOʱÖÓʹÄÜ */
ATIM_TIMX_PWM_CH1_GPIO_CLK_ENABLE();
ATIM_TIMX_PWM_CH2_GPIO_CLK_ENABLE();
ATIM_TIMX_PWM_CH3_GPIO_CLK_ENABLE();
/* ÏÂÇű۵ÄIOʱÖÓʹÄÜ */
M1_LOW_SIDE_U_GPIO_CLK_ENABLE();
M1_LOW_SIDE_V_GPIO_CLK_ENABLE();
M1_LOW_SIDE_W_GPIO_CLK_ENABLE();
/* ÏÂÇű۵ÄIO³õʼ»¯ */
gpio_init_struct.Pin = M1_LOW_SIDE_U_PIN;
gpio_init_struct.Pull = GPIO_NOPULL;
gpio_init_struct.Speed = GPIO_SPEED_HIGH;
gpio_init_struct.Mode = GPIO_MODE_OUTPUT_PP; /* ÍÆÍìÊä³öģʽ */
HAL_GPIO_Init(M1_LOW_SIDE_U_PORT, &gpio_init_struct);
gpio_init_struct.Pin = M1_LOW_SIDE_V_PIN;
HAL_GPIO_Init(M1_LOW_SIDE_V_PORT, &gpio_init_struct);
gpio_init_struct.Pin = M1_LOW_SIDE_W_PIN;
HAL_GPIO_Init(M1_LOW_SIDE_W_PORT, &gpio_init_struct);
/* ÉÏÇűۼ´¶¨Ê±Æ÷IO³õʼ»¯ */
gpio_init_struct.Pin = ATIM_TIMX_PWM_CH1_GPIO_PIN; /* ͨµÀyµÄGPIO¿Ú */
gpio_init_struct.Mode = GPIO_MODE_AF_PP; /* ¸´ÓÃÍÆÍìÊä³ö */
gpio_init_struct.Pull = GPIO_NOPULL; /* ÉÏÀ­ */
gpio_init_struct.Speed = GPIO_SPEED_FREQ_HIGH; /* ¸ßËÙ */
gpio_init_struct.Alternate = ATIM_TIMX_PWM_CHY_GPIO_AF; /* ¶Ë¿Ú¸´Óà */
HAL_GPIO_Init(ATIM_TIMX_PWM_CH1_GPIO_PORT, &gpio_init_struct);
gpio_init_struct.Pin = ATIM_TIMX_PWM_CH2_GPIO_PIN; /* ͨµÀyµÄCPIO¿Ú */
HAL_GPIO_Init(ATIM_TIMX_PWM_CH2_GPIO_PORT, &gpio_init_struct);
gpio_init_struct.Pin = ATIM_TIMX_PWM_CH3_GPIO_PIN; /* ͨµÀyµÄCPIO¿Ú */
HAL_GPIO_Init(ATIM_TIMX_PWM_CH3_GPIO_PORT, &gpio_init_struct);
//HAL_NVIC_SetPriority(TIM5_IRQn,2, 2);
HAL_NVIC_EnableIRQ(TIM5_IRQn);
HAL_NVIC_SetPriority(TIM5_IRQn,2, 2);
}
}
/**
* @brief ¶¨Ê±Æ÷ÖжϷþÎñº¯Êý
* @param ÎÞ
* @retval ÎÞ
*/
void ATIM_TIMX_PWM_IRQHandler(void)
{
HAL_TIM_IRQHandler(&g_atimx_handle);
}
/**
* @brief ¶¨Ê±Æ÷Öжϻص÷
* @param htim:¶¨Ê±Æ÷¾ä±ú
* @retval ÎÞ
*/
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
if(htim->Instance == ATIM_TIMX_PWM) /* 55us */
{
/* ¹Ø±Õ LED0 */
g_bldc_motor1.step_sta= hallsensor_get_state();
// if((g_bldc_motor1.step_sta <= 6)&&(g_bldc_motor1.step_sta >= 1))/* Åжϻô¶û×éºÏÖµÊÇ·ñÕý³£ */
// {
// pfunclist_m1[g_bldc_motor1.step_sta-1](); /* ͨ¹ýÊý×é³ÉÔ±²éÕÒ¶ÔÓ¦µÄº¯ÊýÖ¸Õë */
//
// }
switch( g_bldc_motor1.step_sta)
{
case 0x01: m1_blch();break;
case 0x02: m1_albh();break;
case 0x03: m1_alch();break;
case 0x04: m1_ahcl();break;
case 0x05: m1_ahbl();break;
case 0x06: m1_bhcl() ;break;
default : break;
}
// switch(g_bldc_motor1.step_sta)
// {
// case 0x01: m2_bhcl() ;break;
// case 0x02: m2_ahbl() ;break;
// case 0x03: m2_ahcl() ;break;
// case 0x04: m2_alch() ;break;
// case 0x05: m2_albh() ;break;
// case 0x06: m2_blch() ;break;
// default : break;
// }
// }
}
}
///**
// * @brief ¶¨Ê±Æ÷Öжϻص÷
// * @param htim:¶¨Ê±Æ÷¾ä±ú
// * @retval ÎÞ
// */
//void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
//{
// if(htim->Instance == ATIM_TIMX_PWM) /* 55us */
// {
// //HAL_GPIO_WritePin(LED0_GPIO_PORT, LED0_GPIO_PIN, GPIO_PIN_SET); /* ¹Ø±Õ LED0 */
// g_bldc_motor1.step_sta= hallsensor_get_state();
//// if(g_bldc_motor1.run_flag == 1)
//// {
//
// switch( g_bldc_motor1.step_sta)
// {
// case 0x01: m1_blch() ;break;
// case 0x02: m1_albh() ;break;
// case 0x03: m1_alch() ;break;
// case 0x04: m1_ahcl() ;break;
// case 0x05: m1_ahbl() ;break;
// case 0x06: m1_bhcl() ;break;
// default : break;
// }
//
//// switch(g_bldc_motor1.step_sta)
//// {
//// case 0x01: m2_bhcl() ;break;
//// case 0x02: m2_ahbl() ;break;
//// case 0x03: m2_ahcl() ;break;
//// case 0x04: m2_alch() ;break;
//// case 0x05: m2_albh() ;break;
//// case 0x06: m2_blch() ;break;
//// default : break;
//// }
//
//
// // }
//
//
// }
//}
cpld程序
//////////////////////////////////////////////////////////////////////////////////
// Company: delong
// Engineer: zhanghuatong
//
// Create Date: 2023/05/04 17:07:59
// Design Name: dj_ctrl
// Module Name: dj_ctrl_top
// Project Name: dj_ctrl_top
// Target Devices: EF2M45_LQFP48
// Tool Versions: TD5.0.5
// Description:
// 1. top level module
// 2. Realize interconnection of various sub modules
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module dj_ctrl_top
(
input ha01 /*synthesis keep=1*/,
input hb01 /*synthesis keep=1*/,
input hc01 /*synthesis keep=1*/,
input dir01 /*synthesis keep=1*/,
input pwm01 /*synthesis keep=1*/,
output reg gla01 = 'd0 /*synthesis keep=1*/,
output reg gha01 = 'd0 /*synthesis keep=1*/,
output reg glb01 = 'd0 /*synthesis keep=1*/,
output reg ghb01 = 'd0 /*synthesis keep=1*/,
output reg glc01 = 'd0 /*synthesis keep=1*/,
output reg ghc01 = 'd0 /*synthesis keep=1*/,
input ha02 ,
input hb02 ,
input hc02 ,
input dir02 ,
input pwm02 ,
output reg gla02 = 'd0 ,
output reg gha02 = 'd0 ,
output reg glb02 = 'd0 ,
output reg ghb02 = 'd0 ,
output reg glc02 = 'd0 ,
output reg ghc02 = 'd0 ,
input ha03 ,
input hb03 ,
input hc03 ,
input dir03 ,
input pwm03 ,
output reg gla03 = 'd0 ,
output reg gha03 = 'd0 ,
output reg glb03 = 'd0 ,
output reg ghb03 = 'd0 ,
output reg glc03 = 'd0 ,
output reg ghc03 = 'd0 ,
input ha04 ,
input hb04 ,
input hc04 ,
input dir04 ,
input pwm04 ,
output reg gla04 = 'd0 ,
output reg gha04 = 'd0 ,
output reg glb04 = 'd0 ,
output reg ghb04 = 'd0 ,
output reg glc04 = 'd0 ,
output reg ghc04 = 'd0
);
wire [4:0] state01;
wire [4:0] state02;
wire [4:0] state03;
wire [4:0] state04;
assign state01 = {dir01,ha01,hb01,hc01};
assign state02 = {dir02,ha02,hb02,hc02};
assign state03 = {dir03,ha03,hb03,hc03};
assign state04 = {dir04,ha04,hb04,hc04};
always @(*)
begin
case (state01)
4'b0001:begin gha01 = 0; gla01 = 0; ghb01 = 0; glb01 = 1; ghc01 = pwm01; glc01 = 0; end
4'b0011:begin gha01 = 0; gla01 = 1; ghb01 = 0; glb01 = 0; ghc01 = pwm01; glc01 = 0; end
4'b0010:begin gha01 = 0; gla01 = 1; ghb01 = pwm01; glb01 = 0; ghc01 = 0; glc01 = 0; end
4'b0110:begin gha01 = 0; gla01 = 0; ghb01 = pwm01; glb01 = 0; ghc01 = 0; glc01 = 1; end
4'b0100:begin gha01 = pwm01; gla01 = 0; ghb01 = 0; glb01 = 0; ghc01 = 0; glc01 = 1; end
4'b0101:begin gha01 = pwm01; gla01 = 0; ghb01 = 0; glb01 = 1; ghc01 = 0; glc01 = 0; end
4'b1001:begin gha01 = 0; gla01 = 0; ghb01 = pwm01; glb01 = 0; ghc01 = 0; glc01 = 1; end
4'b1011:begin gha01 = pwm01; gla01 = 0; ghb01 = 0; glb01 = 0; ghc01 = 0; glc01 = 1; end
4'b1010:begin gha01 = pwm01; gla01 = 0; ghb01 = 0; glb01 = 1; ghc01 = 0; glc01 = 0; end
4'b1110:begin gha01 = 0; gla01 = 0; ghb01 = 0; glb01 = 1; ghc01 = pwm01; glc01 = 0; end
4'b1100:begin gha01 = 0; gla01 = 1; ghb01 = 0; glb01 = 0; ghc01 = pwm01; glc01 = 0; end
4'b1101:begin gha01 = 0; gla01 = 1; ghb01 = pwm01; glb01 = 0; ghc01 = 0; glc01 = 0; end
default :begin gha01 = 0; gla01 = 0; ghb01 = 0; glb01 = 0; ghc01 = 0; glc01 = 0; end
endcase
end
always @(*)
begin
case (state02)
4'b0001:begin gha02 = 0; gla02 = 0; ghb02 = 0; glb02 = pwm02; ghc02 = pwm02; glc02 = 0; end
4'b0011:begin gha02 = 0; gla02 = pwm02; ghb02 = 0; glb02 = 0; ghc02 = pwm02; glc02 = 0; end
4'b0010:begin gha02 = 0; gla02 = pwm02; ghb02 = pwm02; glb02 = 0; ghc02 = 0; glc02 = 0; end
4'b0110:begin gha02 = 0; gla02 = 0; ghb02 = pwm02; glb02 = 0; ghc02 = 0; glc02 = pwm02; end
4'b0100:begin gha02 = pwm02; gla02 = 0; ghb02 = 0; glb02 = 0; ghc02 = 0; glc02 = pwm02; end
4'b0101:begin gha02 = pwm02; gla02 = 0; ghb02 = 0; glb02 = pwm02; ghc02 = 0; glc02 = 0; end
4'b1001:begin gha02 = 0; gla02 = 0; ghb02 = pwm02; glb02 = 0; ghc02 = 0; glc02 = pwm02; end
4'b1011:begin gha02 = pwm02; gla02 = 0; ghb02 = 0; glb02 = 0; ghc02 = 0; glc02 = pwm02; end
4'b1010:begin gha02 = pwm02; gla02 = 0; ghb02 = 0; glb02 = pwm02; ghc02 = 0; glc02 = 0; end
4'b1110:begin gha02 = 0; gla02 = 0; ghb02 = 0; glb02 = pwm02; ghc02 = pwm02; glc02 = 0; end
4'b1100:begin gha02 = 0; gla02 = pwm02; ghb02 = 0; glb02 = 0; ghc02 = pwm02; glc02 = 0; end
4'b1101:begin gha02 = 0; gla02 = pwm02; ghb02 = pwm02; glb02 = 0; ghc02 = 0; glc02 = 0; end
default :begin gha02 = 0; gla02 = 0; ghb02 = 0; glb02 = 0; ghc02 = 0; glc02 = 0; end
endcase
end
always @(*)
begin
case (state03)
4'b0001:begin gha03 = pwm03; gla03 = 0; ghb03 = 0; glb03 = 0; ghc03 = 0; glc03 = pwm03; end
4'b0011:begin gha03 = 0; gla03 = pwm03; ghb03 = pwm03; glb03 = 0; ghc03 = 0; glc03 = 0; end
4'b0010:begin gha03 = 0; gla03 = 0; ghb03 = 0; glb03 = pwm03; ghc03 = pwm03; glc03 = 0; end
4'b0110:begin gha03 = 0; gla03 = pwm03; ghb03 = 0; glb03 = 0; ghc03 = pwm03; glc03 = 0; end
4'b0100:begin gha03 = pwm03; gla03 = 0; ghb03 = 0; glb03 = pwm03; ghc03 = 0; glc03 = 0; end
4'b0101:begin gha03 = 0; gla03 = 0; ghb03 = pwm03; glb03 = 0; ghc03 = 0; glc03 = pwm03; end
4'b1001:begin gha03 = 0; gla03 = pwm03; ghb03 = 0; glb03 = 0; ghc03 = pwm03; glc03 = 0; end
4'b1011:begin gha03 = pwm03; gla03 = 0; ghb03 = 0; glb03 = pwm03; ghc03 = 0; glc03 = 0; end
4'b1010:begin gha03 = 0; gla03 = 0; ghb03 = pwm03; glb03 = 0; ghc03 = 0; glc03 = pwm03; end
4'b1110:begin gha03 = pwm03; gla03 = 0; ghb03 = 0; glb03 = 0; ghc03 = 0; glc03 = pwm03; end
4'b1100:begin gha03 = 0; gla03 = pwm03; ghb03 = pwm03; glb03 = 0; ghc03 = 0; glc03 = 0; end
4'b1101:begin gha03 = 0; gla03 = 0; ghb03 = 0; glb03 = pwm03; ghc03 = pwm03; glc03 = 0; end
default :begin gha03 = 0; gla03 = 0; ghb03 = 0; glb03 = 0; ghc03 = 0; glc03 = 0; end
endcase
end
always @(*)
begin
case (state04)
4'b0001:begin gha04 = pwm04; gla04 = 0; ghb04 = 0; glb04 = 0; ghc04 = 0; glc04 = pwm04; end
4'b0011:begin gha04 = 0; gla04 = pwm04; ghb04 = pwm04; glb04 = 0; ghc04 = 0; glc04 = 0; end
4'b0010:begin gha04 = 0; gla04 = 0; ghb04 = 0; glb04 = pwm04; ghc04 = pwm04; glc04 = 0; end
4'b0110:begin gha04 = 0; gla04 = pwm04; ghb04 = 0; glb04 = 0; ghc04 = pwm04; glc04 = 0; end
4'b0100:begin gha04 = pwm04; gla04 = 0; ghb04 = 0; glb04 = pwm04; ghc04 = 0; glc04 = 0; end
4'b0101:begin gha04 = 0; gla04 = 0; ghb04 = pwm04; glb04 = 0; ghc04 = 0; glc04 = pwm04; end
4'b1001:begin gha04 = 0; gla04 = pwm04; ghb04 = 0; glb04 = 0; ghc04 = pwm04; glc04 = 0; end
4'b1011:begin gha04 = pwm01; gla04 = 0; ghb04 = 0; glb04 = pwm04; ghc04 = 0; glc04 = 0; end
4'b1010:begin gha04 = 0; gla04 = 0; ghb04 = pwm04; glb04 = 0; ghc04 = 0; glc04 = pwm04; end
4'b1110:begin gha04 = pwm04; gla04 = 0; ghb04 = 0; glb04 = 0; ghc04 = 0; glc04 = pwm04; end
4'b1100:begin gha04 = 0; gla04 = pwm04; ghb04 = pwm04; glb04 = 0; ghc04 = 0; glc04 = 0; end
4'b1101:begin gha04 = 0; gla04 = 0; ghb04 = 0; glb04 = pwm04; ghc04 = pwm04; glc04 = 0; end
default :begin gha04 = 0; gla04 = 0; ghb04 = 0; glb04 = 0; ghc04 = 0; glc04 = 0; end
endcase
end
endmodule
我来回答