jaycribs
Newbie level 3
im trying to write a code to charge the capacitor on the an IR sensor and see the discharge time on a oscilloscope
im using a pwm to charge the capacitor but i have to be able to change my output pin to an input pin after 10ms to see the discharge.
this is my code but i keep getting errors . i cant figure out wats wrong. Pls help me Thank you
module sense( clock,pwm,
);
parameter d = 195;
parameter cs = 100000;
parameter sw = 4;
input clock;
inout pwm;
reg [15:0] counter = 0;
wire pwm;
wire pwm_out;
assign pwm = (pwm_out==1) ? 1'bz :1'bz; // trying to change to input
always @(posedge clock)
begin // PWM generation
counter = counter+1; // Increment counter
if(counter <= sw*d) pwm <= 1;
else pwm_out <= 0;
if (counter >=cs) counter = 0; // Resets the counter
end
endmodule
im using a pwm to charge the capacitor but i have to be able to change my output pin to an input pin after 10ms to see the discharge.
this is my code but i keep getting errors . i cant figure out wats wrong. Pls help me Thank you
module sense( clock,pwm,
);
parameter d = 195;
parameter cs = 100000;
parameter sw = 4;
input clock;
inout pwm;
reg [15:0] counter = 0;
wire pwm;
wire pwm_out;
assign pwm = (pwm_out==1) ? 1'bz :1'bz; // trying to change to input
always @(posedge clock)
begin // PWM generation
counter = counter+1; // Increment counter
if(counter <= sw*d) pwm <= 1;
else pwm_out <= 0;
if (counter >=cs) counter = 0; // Resets the counter
end
endmodule