I am trying to intercept a signal to drive a scanbar. The old bar has a clock in of 4MHz and requires a one clock pulse start trigger. We are testing another bar that needs a four clock pulse instead. (Scanbar runs on 3.3V logic)
So I grabbed the mbed and built a routine that looks for the start pulse as an interrupt in and then puts a 960ns pulse on a digital out pin.
I know that the signal in is seen as I have a message that goes out to the LCD. But the oscope never sees a pulse on the digital out pin.
Maybe I missed something in setting things up?
Here is the code:
<<code>>
- include "mbed.h"
- include "TextLCD_20X4.h"
TextLCD_20X4 lcd(p5, p6, p7, p8, p9, p10); rs, e, d4, d5, d6, d7
DigitalOut myled(LED1);
DigitalOut test_pin(p21);
InterruptIn Start_pulse_In(p30);
DigitalOut Start_pulse_Out(p27);
int spacer = 16;
void scan () {
Start_pulse_Out = 1;
wait_us(0.1);
while (spacer > 0) {
spacer;
}
spacer = 16;
Start_pulse_Out = 0;
lcd.locate(0,1);
lcd.printf("Start Pulse!");
}
int main() {
lcd.locate(6,0);
lcd.printf("Mad_Lab");
lcd.locate(0,2);
lcd.printf("SystemCoreClock = %d Hz\n", SystemCoreClock);
Start_pulse_Out = 0;
Start_pulse_In.rise(&scan);
test_pin = 0;
while(1) {
myled = 1;
test_pin = 1;
wait(0.2);
myled = 0;
test_pin = 0;
wait(0.2);
}
}
<<code>>
Probably something basic wrong, been a while since I was really digging into code.
I am trying to intercept a signal to drive a scanbar. The old bar has a clock in of 4MHz and requires a one clock pulse start trigger. We are testing another bar that needs a four clock pulse instead. (Scanbar runs on 3.3V logic)
So I grabbed the mbed and built a routine that looks for the start pulse as an interrupt in and then puts a 960ns pulse on a digital out pin.
I know that the signal in is seen as I have a message that goes out to the LCD. But the oscope never sees a pulse on the digital out pin.
Maybe I missed something in setting things up?
Here is the code:
<<code>>
TextLCD_20X4 lcd(p5, p6, p7, p8, p9, p10); rs, e, d4, d5, d6, d7
DigitalOut myled(LED1); DigitalOut test_pin(p21); InterruptIn Start_pulse_In(p30); DigitalOut Start_pulse_Out(p27);
int spacer = 16;
void scan () { Start_pulse_Out = 1; wait_us(0.1); while (spacer > 0) { spacer
; } spacer = 16; Start_pulse_Out = 0; lcd.locate(0,1); lcd.printf("Start Pulse!"); }int main() {
lcd.locate(6,0); lcd.printf("Mad_Lab");
lcd.locate(0,2); lcd.printf("SystemCoreClock = %d Hz\n", SystemCoreClock);
Start_pulse_Out = 0;
Start_pulse_In.rise(&scan);
test_pin = 0; while(1) { myled = 1; test_pin = 1; wait(0.2); myled = 0; test_pin = 0; wait(0.2); } }
<<code>>
Probably something basic wrong, been a while since I was really digging into code.