May 11, 2023

Brute Force Techniques I

This is a description

Triangular (Sawtooth) Waves

#include <LPC17xx.H>

int main()
{
	unsigned long int temp = 0x00000000;
	unsigned int i = 0;

	LPC_PINCON->PINSEL0 &= 0xFF0000FF; // Configure P0.4 to P0.11 as GPIO
	LPC_GPIO0->FIODIR |= 0x00000FF0;
	LPC_GPIO0->FIOMASK = 0XFFFFF00F;

	while (1)
	{
		// output 0 to FE
		for (i = 0; i != 0xFF; i++)
		{
			temp = i;
			temp = temp << 4;
			LPC_GPIO0->FIOPIN = temp;
		}
		// output FF to 1
		for (i = 0xFF; i != 0; i--)
		{
			temp = i;
			temp = temp << 4;
			LPC_GPIO0->FIOPIN = temp;
		}
	}
}

Square Waves

#include <LPC17xx.H>

void delay(void);

int main()
{
	LPC_PINCON->PINSEL0 &= 0xFF0000FF; // Configure P0.4 to P0.11 as GPIO
	LPC_GPIO0->FIODIR |= 0x00000FF0;
	LPC_GPIO0->FIOMASK = 0XFFFFF00F;
	while (1)
	{
		LPC_GPIO0->FIOPIN = 0x00000FF0;
		delay();
		LPC_GPIO0->FIOCLR = 0x00000FF0;
		delay();
	}
}

void delay(void)
{
	unsigned int i = 0;
	for (i = 0; i <= 9500; i++)
		;
}

Sine Waves

#include <LPC17xx.H>

int count = 0, sinevalue, value;
unsigned char sine_tab[49] = {
		0x80, 0x90, 0xA1, 0xB1, 0xC0, 0xCD, 0xDA, 0xE5, 0xEE, 0xF6, 0xFB, 0xFE,
		0xFF, 0xFE, 0xFB, 0xF6, 0xEE, 0xE5, 0xDA, 0xCD, 0xC0, 0xB1, 0xA1, 0x90,
		0x80, 0x70, 0x5F, 0x4F, 0x40, 0x33, 0x26, 0x1B, 0x12, 0x0A, 0x05, 0x02,
		0x00, 0x02, 0x05, 0x0A, 0x12, 0x1B, 0x26, 0x33, 0x40, 0x4F, 0x5F, 0x70, 0x80
};

int main(void)
{
	LPC_PINCON->PINSEL0 &= 0xFF0000FF; // Configure P0.0 to P0.15 as GPIO
	LPC_GPIO0->FIODIR |= 0x00000FF0;
	LPC_GPIO0->FIOMASK = 0XFFFFF00F;

	count = 0;
	while (1)
	{
		for (count = 0; count < 48; count++)
		{
			sinevalue = sine_tab[count]; //+0X10 ;
			value = 0x00000FF0 & (sinevalue << 4);
			LPC_GPIO0->FIOPIN = value;
		}
	}
}