jackcmos
Newbie level 1
- Joined
- Feb 6, 2009
- Messages
- 1
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,289
i am new learner try to do the following task:
The system required is to act as a simple oscilloscope, utilising a 256x256 display to graph the analogue inputs to a microcontroller.
The microcontroller is a 32 bit machine, big-endian. Memory addresses are directed to bytes, with 16 bit accesses limited to even addresses, and 32 bit accesses limited to multiples of 4.
The ADC has a resolution of 16 bits, and can do an A/D conversion in a single instruction
The memory map of the micro is as follows:
You have been provided with the following function prototypes:
1) How might Display_SetPixel be coded?
2) Write the code to plot the ADC readings on the display, to act as an oscilloscope. Please list any assumptions you have made about the system.
The system required is to act as a simple oscilloscope, utilising a 256x256 display to graph the analogue inputs to a microcontroller.
The microcontroller is a 32 bit machine, big-endian. Memory addresses are directed to bytes, with 16 bit accesses limited to even addresses, and 32 bit accesses limited to multiples of 4.
The ADC has a resolution of 16 bits, and can do an A/D conversion in a single instruction
The memory map of the micro is as follows:
0x00000..0x0FFFF Code/data space
0x10000..0x1FFFF Display, 8 bits wide, mapped x first
0x20000..0x20001 A/D
You have been provided with the following function prototypes:
Code:
typedef unsigned short ushort;
typedef unsigned char ubyte;
void Display_Clear( void );
void Display_SetPixel( ushort x, ushort y, ubyte intensity );
short ADC_Read( void );
1) How might Display_SetPixel be coded?
Code:
//my code, but i think it might not correct.
void Display_SetPixel( ushort x, ushort y, ubyte intensity )
{
int DisplayBufferSize = (x * y);
unsigned char DisplayImage [DisplayBufferSize / 8];
// here I assumed bytes describe the vertical stripes
unsigned char * byte = &DisplayImage[x + (y / 8) * x];
if (intensity)
*byte |= 1 << (x % 8);
else
*byte &= ~(1 << (x % 8));
}
2) Write the code to plot the ADC readings on the display, to act as an oscilloscope. Please list any assumptions you have made about the system.
Code:
adc_result = (ReadADC()) / 2;
Display_Clear();
//how to match the adc_result on to the display???
//please help!
Last edited by a moderator: