CCS/FinalCode/main.c
//Note - expects flash segment to be erased first
expects flash segment to be erased first
expects flash segment to be erased first
void WriteFlash(char MsgIndex, unsigned int ValIndex, char Value)
{
	char *Flash_ptr;                          
	switch(MsgIndex)
	{
		case 1:
			Flash_ptr = (char *) (START0+ValIndex);              
			break;
		case 2:
			Flash_ptr = (char *) (START1+ValIndex);              
			break;
		case 3:
			Flash_ptr = (char *) (START2+ValIndex);              
			break;
		case 5:
			Flash_ptr = (char *) (STARTTMP+ValIndex);              
			break;
	}
	FCTL1 = FWKEY + ERASE;                      
	FCTL3 = FWKEY;                            
	FCTL1 = FWKEY + WRT;
	*Flash_ptr = Value;
	FCTL1 = FWKEY;                            
	FCTL3 = FWKEY + LOCK;                     
}
void WriteFlash ( char MsgIndex , unsigned int ValIndex , char Value ) { char * Flash_ptr ; switch ( MsgIndex ) { case 1 : Flash_ptr = ( char * ) ( START0 + ValIndex ) ; break ; case 2 : Flash_ptr = ( char * ) ( START1 + ValIndex ) ; break ; case 3 : Flash_ptr = ( char * ) ( START2 + ValIndex ) ; break ; case 5 : Flash_ptr = ( char * ) ( STARTTMP + ValIndex ) ; break ; } FCTL1 = FWKEY + ERASE ; FCTL3 = FWKEY ; FCTL1 = FWKEY + WRT ; * Flash_ptr = Value ; FCTL1 = FWKEY ; FCTL3 = FWKEY + LOCK ; }
Note - expects flash segment to be erased first
Note - expects flash segment to be erased first
// Flash pointer // Initialize Flash pointer // Initialize Flash pointer // Initialize Flash pointer // Initialize Flash pointer // Set WRT bit for write operation // Clear Lock bit // Clear WRT bit // Set LOCK bit