You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I am currently doing unit testing with xc8 compiler on simulator using this project as a baseline.
I was trying to merge an SCL script from MPLABX Stimulus where I am simply setting a pin high and then testing that pin in my test file.
I can easily use Stim command to add an SCL file in sim_instructions.txt file.
Now when I run my test file with ceedling, I can see that the scl script successfully runs before my test file but does not carry the changes to RB0 state in gpio_access.c as it prints out "RB0 is Low".
I am attaching codes below for better understanding.
Output is also attached in the end.
gpio_access.c
int GPIO_SetVar(void)
{
if(PORTBbits.RB0)
printf("RB0 is High\n");
else
printf("RB0 is Low\n");
return 1;
}
test_gpio_access.c
void setUp(void)
{
}
void tearDown(void)
{
}
void test_GPIO_SetVar(void)
{
int x = GPIO_SetVar();
TEST_ASSERT_EQUAL(1, x);
}
sim_instructions.txt
device PIC18F26Q10
set oscillator.frequency 32
set oscillator.frequencyunit Mega
set oscillator.rcfrequency 31
set oscillator.rcfrequencyunit Kilo
set uart1io.uartioenabled true
set uart1io.output stdout
set uart1io.outputfile test/simulation/out.txt
set breakoptions.wdtwarnings Ignore
hwtool sim
program build/ceedling/generated/test/out/test_build.elf
Stim C:\Users\shahbaz.khan\MPLABXProjects\unit_testing\rm3_wifi_ceedling_ut\stimb0.scl
Sleep 5000
Run
Sleep 5000
print pin RB0
Quit
stim_file.scl
//
// C:\Users\shahbaz.khan\MPLABXProjects\unit_testing\rm3_wifi_ceedling_ut\stimb0.scl
// Generated by Stimulus MPLAB X
// Mon Jul 10 14:20:34 AEST 2023
//
configuration for "pic18f26q10" is
end configuration;
testbench for "pic18f26q10" is
begin
// Pin/Register Actions
process is
begin
wait for 0 ic;
report "Stimulus actions after 0 ic";
TRISB.TRISB0 <= '1';
RB0 <= '1';
wait;
end process;
end testbench;
It appears that the issue is related to the fact that changes made to the RB0 pin state in the SCL script are not correctly reflecting in the gpio_access.c file during the test run.
This could be due to a few reasons:
RB0 Pin Configuration: Verify that the RB0 pin configuration is correct in both the SCL script and the gpio_access.c code. Make sure the pin is correctly configured as an output in the SCL script and is being read correctly in the gpio_access.c code.
Insufficient Waiting Time: The waiting time between stimulating the RB0 pin and running the test may not be enough for changes to the pin to be reflected at the time GPIO_SetVar() is called. Try increasing the wait time between these two steps to ensure the changes have enough time to occur.
Pin State Check: Check if the GPIO_SetVar() function is correctly reading the state of the RB0 pin. There may be a problem reading the pin state that is resulting in the incorrect "RB0 is Low" output.
Try making the following changes to resolve the issue:
Verify that the RB0 pin configuration is correct in the SCL scripts and gpio_access.c code.
Increase the delay time between stimulating the RB0 pin and running the test to ensure that pin changes are reflected.
Verify that the GPIO_SetVar() function is correctly reading the state of the RB0 pin and adjust it as necessary.
If the problem persists after these changes, you may need to do more detailed debugging to identify the root cause of the problem.
Hi,
I am currently doing unit testing with xc8 compiler on simulator using this project as a baseline.
I was trying to merge an SCL script from MPLABX Stimulus where I am simply setting a pin high and then testing that pin in my test file.
I can easily use Stim command to add an SCL file in sim_instructions.txt file.
Now when I run my test file with ceedling, I can see that the scl script successfully runs before my test file but does not carry the changes to RB0 state in gpio_access.c as it prints out "RB0 is Low".
I am attaching codes below for better understanding.
Output is also attached in the end.
gpio_access.c
test_gpio_access.c
sim_instructions.txt
stim_file.scl
output dump
The text was updated successfully, but these errors were encountered: