Migrate missed references

Migrated PB5 references to PB0, that were left over from a previous commit. This also fixes the false lock status OK reporting bug.
This commit is contained in:
Marco Vitchi Thulin 2024-03-10 18:08:04 +01:00
parent 660dd4e8de
commit 088864e670

16
main.c
View file

@ -5,7 +5,7 @@
// PB2 - SCK to ADF4350 CLK
// PB1 - DO (MOSI) to ADF4350 DATA
// PB0 - ADF4350 LD
// PB4 - Status LED
// PB4 - Lock Status LED
void Delay(uint32_t);
uint8_t SendReceiveSPIData(uint8_t);
@ -45,11 +45,11 @@ int main()
// set PB3 (LE) low
PORTB &= ~(1 << PORTB3);
// set direction of PB5 (LD Input) as input
// set direction of PB0 (LD Input) as input
DDRB &= ~(1 << DDB0);
// enable pull-up resistor on PB5
PORTB |= (1 << PORTB5);
// enable pull-up resistor on PB0
PORTB |= (1 << PORTB0);
// flash the Status LED (PB4) to show that everything works
PORTB |= (1 << PORTB4);
@ -60,10 +60,10 @@ int main()
// enter loop waiting for frequency lock to be achieved
while (1)
{
// read the state of LD (PB5)
uint8_t ldState = PINB & (1 << PINB5);
// read the state of LD (PB0)
uint8_t ldState = PINB & (1 << PINB0);
// if LD is low, turn on the LED (PB4)
// if LD (PB0) is low, turn on the LED (PB4)
if (ldState == 0)
PORTB |= (1 << PORTB4); // Turn on the LED
else
@ -90,7 +90,7 @@ uint8_t SendReceiveSPIData(uint8_t value)
// prob change the 8 below to len of value?
for(i=0;i<8;i++)
{
///USIDR = value[i]; // wrong way to do it apparently, still saving for future reference
///USIDR = value[i]; // wrong way to do it apparently, still saving for future reference
USIDR = (value >> i) & 0x01; // write data bytes in Data register, will cause them to get sent on clock
while(USIOIF==0) // check USI data counter overflow flag to detect the end of transmission every byte
{