during setup i read a value from internal eeprom address 0 and if it reads 1 it should send data through SPI. The weird thing is that if the call to SPI_Write is inside IF statement no data is sent through SPI but if i move SPI_Write outside the IF then SPI works fine.
The "assigned_par==1" condition is met, i tested by inserting a digitalWrite to a LED
What do your functions SPI_init() and SPI_write() do? I suspect they are doing something wrong. And what libraries are included? And what model Arduino are you using? And how are all those variables declared? And what does the rest of the code do?
You may be confident, but that does not mean you're right. Unless/until you PROVE that, you simply don't know. And by FAR the most plausible explanation is that assigned_par is NOT ==1 when the if expression is evaluated.
I'm going to take a wild guess - I bet assigned_par == 0xff.
And, as already requested, tell us the data type of assigned_par.
The problem is that your basic premise that "SPI in setup() doesn’t work inside if condition" is nonsense. So, there's a problem elsewhere in your code or hardware.
If it were my project, the next step would be to observer the SPI lines with a logic analyzer like this one:
I solved by exporting the compiled sketch as Arduino Uno board and setting fuses for running at 8Mhz with internal oscillator.
So i guess there's a compilation issue when hex file is exported with "ATmega328 on a breadboard". Don't know if this is a user made board or Arduino official.