thank you so much Matticus for the input, this is what I am actually asked to do:
The R character instructs the ATmega328P to read from the EEprom at a specifiedbyte address and return the result in decimal format to the serial monitor. It will befollowed by 3 characters indicating the read address in decimal. (e.g. R000, R010,R123 will read from EEprom addresses 0, 10 and 123 respectively and return thecontents)
here is the snippet of the code I'm concerned with, I am a Newbie but if I can get some help figuring this part out, I can do the rest. the actual program has many other files.
Code:
#include <stdint.h>#include "avr/interrupt.h"
#include "defineFiles.h"
#include "usart.h"
#include <stdio.h>
#include <stdlib.h>
void EnableInterrupts(void)
{
SREG_REG = SREG_REG | BIT7;
}
void DisableInterrupts(void)
{
SREG_REG = SREG_REG & (~BIT7);
}
int main (){
char buffer [256];
int R;
uint8_t W = 0;
init();
InitUsartMode();
EnableInterrupts();
// sprintf ("program begin");
fgets (buffer, 256, stdin);
R = atoi (buffer);
sprintf ("R%d.",R);
//mySerialWrite(&(msg[0]));
while (1){
memset(buffer, 0, sizeof(buffer));
DisableInterrupts(); // critical section
if (rxIndex !=0)
{
W = 1;
for(R = 0; R < rxIndex; R++)
{
buffer [R] = rxBuffer [R];
}
rxIndex = 0;
}
EnableInterrupts();
if (W == 1)
{
W =0;
mySerialWrite(&(buffer[0]));
}
}
return 0;
}