Most controllers in the AVR
family support SPI. AVR has 3 register associated with the SPI.
1. SPSR
(SPI Status Register)
2. SPCR
(SPI Control Register)
3. SPDR
(SPI Data Register)
The blog talks about variety of topics on Embedded System, 8085 microprocessor, 8051 microcontroller, ARM Architecture, C2000 Architecture, C28x, AVR and many many more. Also includes some projects that have been worked upon and also episodes to Embedded System Podcast.
Wikipedia defines Brownout as an intentional or unintentional drop in voltage in an electrical power supply system. Intentional brownouts are used for load reduction in an emergency. The reduction lasts for minutes or hours, as opposed to short-term voltage sag or dip.
Brownouts can cause unexpected behaviour in systems with digital control circuits. Reduced voltages can bring control signals below the threshold at which logic circuits can reliably detect which state is being represented. As the voltage returns to normal levels the logic can latch at an incorrect state; even can't happen states become possible. The seriousness of this effect and whether steps need to be taken by the designer to prevent it depends on the nature of the equipment being controlled; for instance a brownout may cause a motor to begin running backwards.
Interrupt latency is the time that elapses from when an interrupt is generated to when the source of the interrupt is serviced.
Tail-chaining is back-to-back processing of exceptions without the overhead of state saving and restoration between interrupts. The processor skips the pop of eight registers and push of eight registers when exiting one ISR and entering another because this has no effect on the stack contents.
The processor tail-chains if a pending interrupt has higher priority than all stacked exceptions. For more info on Tail Chaining and its Timing Diagram Refer infocentre@arm.
![]() |
Cortex M3 Processor Simplified Block Diagram |
Cortex M3 Processor Block Diagram. Ref ARM.com |
Function
Name
|
Description
|
void Delay1Sec(void);
|
Returns: void
Parameter: void
Description: Creates
a hardware delay of 1 sec using timers and counters.
|
void DelayXSec(unsigned int number);
|
Returns: void
Parameter:
Unsigned int number (Number of Seconds)
Description: Creates
a hardware delay of X secs using timers and counters, the x is the number
provided by the user.
|
void Delay1mSec(void);
|
Returns: void
Parameter: void
Description:
Creates a hardware delay of 1 millisecond using timers and
counters.
|
void DelayXmSec(unsigned int number);
|
Returns: void
Parameter:
Unsigned int number (Number of milliseconds)
Description: Creates
a hardware delay of X milliseconds using timers and counters, the x is the
number provided by the user.
|
Macro
Name
|
Macro
Purpose
|
#define KEY_PRT PORTD
|
Port at which output of keypad to be passed
|
#define KEY_DDR DDRD
|
DDR register for that port. Will define which pins to be considered
as input and which as output
|
#define KEY_PIN PIND
|
Pin for port at which input from the columns of the
keypad will be taken.
|
Function
Name
|
Function
Description
|
void KEYPAD_Init(void);
|
Returns: void
Parameter: void
Description: Initializes
Keypad port and DDR register.
|
unsigned char GetKeyPressed(void);
|
Returns: unsigned
char (char of the key pressed)
Parameter: void
Description: Returns
the character of the key pressed.
|
Macro
Name
|
Macro
Purpose
|
#define LCD_DATA_PORT PORTB
|
Port at which data output to LCD will be passed
|
#define LCD_DATA_DDR DDRB
|
DDR Register for DATA port determining the direction of data.
|
#define LCD_DATA_PIN PINB
|
Pin port for reading data from the buffer of the LCD
|
#define LCD_CMD_PORT PORTA
|
Port at which command to LCD will be passed.
|
#define LCD_CMD_DDR DDRA
|
DDR register for COMMAND port determining the
direction of the command.
|
#define LCD_CMD_PIN PINA
|
Pin port for reading command from command register from command
buffer of LCD.
|
#define LCD_RS 0
|
LCD Register select pin.
|
#define LCD_RW 1
|
LCD read-write pin
|
#define LCD_EN 2
|
LCD Enable Pin
|
Function
Name
|
Function
Description
|
void LCD_Init(void);
|
Returns: void
Parameter: void
Description: Initializes
LCD port and DDR register.
|
void LCD_GotoXY(unsigned char row, unsigned char
col);
|
Returns: void
Parameter: Unsigned
char row and unsigned character column.(meaning x and y)
Description: Jumps
to the row and column as provided by the user.
|
void LCD_Write_Command(unsigned char command);
|
Returns: void
Parameter: unsigned
char command(command in form of hexadecimal or in form of character)
Description: Writes
the command to the LCD
|
void LCD_Write_Data(unsigned char data);
|
Returns: void
Parameter: unsigned
char data (writes the ascii data directly to the LCD buffer hence displaying
it on LCD)
Description: Writes
data to the LCD like text or string.
|
void LCD_Clear(void);
|
Returns: void
Parameter: void
Description: Clears
LCD
|
void LCD_Print(char *str);
|
Returns: void
Parameter: char *
str
Description: Prints
the passed string to the LCD.
|
void LCD_Write_Char(char c);
|
Returns: void
Parameter: char c
Description: Prints
the passed character to the LCD.
|
Function
Name
|
Function
Description
|
void write_eeprom(unsigned char *text)
|
Returns: void
Parameter: unsigned
char *text(text to be written to eeprom)
Description:Writes
text to eeprom.
|
void read_eeprom(unsigned char *text)
|
Returns: void
Parameter: unsigned
char *text(variable to which text is to be written)
Description: Read
the eeprom and writes the read text on the provided variable.
|
Program
Memory Strings
|
Description
|
static const char menuitem_1_line_1[]
PROGMEM= "1) - Enter ";
|
Initialize Items to be written on program memory
|
static const char common_line_2[] PROGMEM= " Password";
|
Initialize Items to be written on program memory
|
static const char menuitem_2_line_1[] PROGMEM= "2) - Change ";
|
Initialize Items to be written on program memory
|
PGM_P string_table[] PROGMEM =
{
menuitem_1_line_1,
common_line_2,
menuitem_2_line_1
};
|
Making strings in program memory accessible by using string table.
|
strcpy_P(buffer,
(PGM_P)pgm_read_word(&(string_table[0])));
|
Using of string table by use of string copy function
as shown. Here buffer is a variable with size equivalent to the number of
columns in the character LCD.
|
Function
Name
|
Function
Description
|
int create_and_show_menu(void);
|
Returns: int(1
or 2 depending on the choice of menu item)
Parameter:
void
Description: Returns
integer value 1 if menu item 1 is selected and 2 if menu item 2 is selected.
|
Function
Name
|
Function
Description
|
void sayHello(void);
|
Returns: void
Parameter:
void
Description: Says
hello on LCD. Can be used as a test function to check connection of LCD.
|
void enter_password_handler(void);
|
Returns: void
Parameter: void
Description: Called
when enter password menu is selected. Does whatever comes after hitting enter
password menu item.
|
void change_password_handler(void);
|
Returns: void
Parameter:
void
Description: Called
when change password menu is selected. Does whatever comes after hitting
change password menu item.
|
void system_error_handler(void);
|
Returns: void
Parameter: void
Description: Called
when non of the though value is arised.
|
void main(void);
|
Returns: void
Parameter:
void
Description: Main
function.
|
MCUCSR = (1<<JTD);
|
Statemen to disable JTAG
|