Other Parts Discussed in Thread: DRV8955
Tool/software:
Hello,
I will do my best to explain my end goal, but I may not be explaining it quite correctly so bear with me.
I am attempting to generate, using one singular pin on the MSP430, a "delayed" PWM signal where the signal begins HIGH (3.3V) for 4ms and then begins to pulse based on my desired frequency and duty cycle. This will be generated based on a GPIO input that comes from an external source.
My approach to this has been:
1) Setup Timer B (corresponding to P4.3)
- Setup CCR0 and CCR3 in UP (MC_1) mode
- Initialize their interrupts by ORing the compare/control register with CCIE
- Initialize the corresponding pin to a GPIO pin initially
2) Setup Timer A (only using this Timer to count to 4ms)
- Setup CCR0 to hold a value of 32000, @8MHz DCOCLK this should be equal to 4ms
- Initialize the interrupt the same way as Timer B
3) Setup all the corresponding GPIO, in this case I am using P6.5 (yes, I know, I should have probably routed this signal to P1 or P2 so I can use a hardware interrupt, but I am trying to do this with software polling, that might be my problem as to why I cannot get this to work)
- Initialize P6.5 as a GPIO input that is a pull down
4) In my main, create an infinite loop using while(1),
if(trigger_input) -> set P4.3 high using P4OUT |= BIT3 -> activate Timer A -> in Timer A IRQ, set P4.3 to a PWM pin using P4SEL |= BIT3 -> activate Timer B -> flip flop between IRQ for CCR0 and CCR3 in TB.
This does not seem to work, or, rather, it seems to work "sometimes".
To give a little bit more context: I am trying to use this PWM signal as an input to DRV8955, a motor driver chip that has 4 PWM inputs and 4 PWM outputs. For some reason, I cannot seem to see the initial GPIO pulse with the "delay" prior to the actual PWM itself on the output. Also - for whatever reason, my initial delay is only 1.5ms instead of 4ms and I'm not sure why. The code I am using to set my clock to 8MHz is the following:
DCOCTL = CALDCO_8MHZ; //Change DCO = MCLK = 8 MHz
BCSCTL1 = CALBC1_8MHZ | XTS; //Basic clock system control register
Any insight into how to properly do this would be great! I can post the entirety of my code as well to go over any nuances but I did not want to make this post too much of an essay.
Thank you in advance, this has been an issue I've been working on for almost two weeks now with no luck.
My desired waveform looks as follows: