Okay 1 day down using the MikroBasic Pro for Arm along with the MINI-M4 for STM32
Success in getting the USB Hid routines to send packets back and forth and getting head around long GPIO routines to set up pins to switch on and off LEDS.
Next I wanted to kick the PWM off but all I ever see on the scope, via Port PA8 is 100MHz pulse.
Here is very rough cut and paste code
Code: Select all
program Testing
dim STAT_LED as sbit at ODR13_GPIOC_ODR_bit
dim DATA_LED as sbit at ODR12_GPIOC_ODR_bit
dim cnt as byte
dim readbuff as byte[64]
dim writebuff as byte[64]
dim current_duty as word
pwm_period1 as word
sub procedure USB1Interrupt() iv IVT_INT_OTG_FS
USB_Interrupt_Proc()
end sub
main:
GPIO_Digital_Output(@GPIOC_BASE, _GPIO_PINMASK_12 or _GPIO_PINMASK_13)
current_duty = 50 ' initial value for current_duty
pwm_period1 = PWM_TIM1_Init(2000)
PWM_TIM1_Set_Duty(current_duty, _PWM_NON_INVERTED, _PWM_CHANNEL1) ' Set current duty for PWM_TIM1
PWM_TIM1_Start(_PWM_CHANNEL1, @_GPIO_MODULE_TIM1_CH1_PA8)
HID_Enable(@readbuff,@writebuff)
loopit:
if hid_read=0 then
else
if readbuff[0]="1" then
Delay_ms(1)
current_duty = current_duty + 5 ' increment current_duty
if (current_duty > pwm_period1) then ' if we increase current_duty greater then possible pwm_period1 value
current_duty = 0 ' reset current_duty value to zero
end if
PWM_TIM1_Set_Duty(current_duty, _PWM_NON_INVERTED, _PWM_CHANNEL1) ' set newly acquired duty ratio
STAT_LED = 1
end if
if readbuff[0]="2" then
Delay_ms(1)
current_duty = current_duty - 5 ' decrement current_duty
if (current_duty > pwm_period1) then ' if we decrease current_duty greater then possible pwm_period1 value (overflow)
current_duty = pwm_period1 ' set current_duty to max possible value
end if
PWM_TIM1_Set_Duty(current_duty, _PWM_NON_INVERTED, _PWM_CHANNEL1) ' set newly acquired duty ratio
DATA_LED = 1
end if
writebuff[0]=lo(current_duty)
writebuff[1]=hi(current_duty)
HID_Write(@writebuff,64)
end if
DATA_LED = 0
STAT_LED = 0
goto loopit
end.
I set speed to 120MHz as using the bootloader.
Any help or tips appreciated.
Cheers
Sean.