1000 kişiden bir kişi için ! devam.... 320volt blog

Elektronik Devreler Projeler » Atmel devreleri bilgiler »

Nokia 3410 atmega8 2.4 ghz spectrum analyzer devresi

2-4-GHz-Spectrum-Analyzer-nokia

Cep telefonlarının lcd ekranları mikrodenetleyiciler ile sık sık kullanılıyor nokia 3410 lcd atmel atmega8 ve cywm6935 modül ile 2.4 ghz spectrum analyzer devresi yapılmış

Devrenin kod ve şema dosyaları : Handheld 2.4 GHz Spectrum Analyzer

nokia3410-lcd-atmel-atmega8 -cywm6935

main.c yazılım içeriği


// EA4EOZ's Handheld 2.4 GHz Spectrum Analyzer
//
// This code is based on ideas and functions taken from these places:
//
// DIY 2.4GHz Spectrum Analyser
// |
// |---> http://www.wireless.org.au/%7Ejhecker/specan/
//
//
// LCD Nokia 3310 (PCD8544) Driver in WinAVR(avr-gcc)
// |
// |---> http://fandigunawan.wordpress.com/2008/06/18/lcd-nokia-3310-pcd8544-driver-in-winavravr-gcc/
//
//
// scrying:module_spectrum
// |
// |---> http://scrying.org/doku.php?id=scrying:module_spectrum
// |
// |---> http://1010.co.uk/spectrumtest.c
//
//
// Atmel AVR code for using Cypress Wireless USB modules
// |
// |---> http://code.google.com/p/cywusb/
//
//
// Simple C code snippets for CYWM6935 RF module
// |
// |---> http://www.topix.com/forum/com/cy/TOGETOVMOQ6THO15B
//
//
// I wish to thank you all for share your experiences with the rest of us.

#include "main.h"

// Main
int main(void){
	static unsigned char signal[LCD_VISIBLE_X_RES];
	unsigned char fast=0;
	unsigned char adding=0;
	unsigned char voltage[4];
	unsigned int volt;
	unsigned char s;
	unsigned char z;

	// Hardware initialization
	SPI_Init();
	LCD_Init();
	RADIO_Init();
	ADC_Init();
	KBRD_Init();
	// Draw the scale at line 5
	memcpy_P(LcdCache+(LCD_VISIBLE_X_RES*5),scale,192);
	// Main loop
	while(1){
		// Start an ACD conversion
		ADC_Conversion();
		// if left key is pressed, toggle "adding"
		if (KBRD_L()) adding = ~adding;
		// Read if right key is pressed
		z=KBRD_R();
		if (adding){
			// If mode is adding, clear signal array
			if (z) memset(signal,0x00,LCD_VISIBLE_X_RES);
		}else{
			// If mode is normal, toggle "fast"
			if (z) fast = ~fast;
		}
		// Read signals and process according "adding" and "fast"
		for (unsigned char n=0; nsignal[n]) signal[n]=s;
			}else{
				// Mode normal
				if (fast){
					// if fast, nothing to do
					signal[n]=s;
				}else{
					// normal-slow
					if (s>signal[n]){
						// If signal if greater, update
						signal[n]=s;
					} else {
						// if not, decrease it
						if (signal[n]!=0) signal[n]--;
					}
				}
			}
		}
		// Draw the signal array
		for (unsigned char n=0; n0, CPHA->0, Clk/4
    SPCR = 0x50;
}

// Send-receive a byte through SPI interface
unsigned char SPI(unsigned char data){
	// Send data
	SPDR=data;
	// Wait until data is sent
	while( ( SPSR & 0x80 ) != 0x80 );
	// Return received byte
	return SPDR;
}

// LCD functions

unsigned int LcdCacheIdx;

// Send data to LCD controller
void LCD_Send(LcdCmdData cd, unsigned char data){
	// Set D/C line
    if (cd == LCD_DATA)
		LCD_PORT |= _BV(LCD_DC_PIN);
    else
		LCD_PORT &= ~(_BV(LCD_DC_PIN));
    // Enable display controller (active low)
    LCD_PORT &= ~(_BV(LCD_CE_PIN));
    // Send data
	SPI(data);
    // Disable display controller
    LCD_PORT |= _BV( LCD_CE_PIN );
}

// Initializes LCD
void LCD_Init(void){
	// Set LCD output pins
    LCD_DDR |= _BV(LCD_RST_PIN) | _BV(LCD_DC_PIN);
    // Resets the LCD controler
    LCD_PORT &= ~(_BV(LCD_RST_PIN));
    _delay_ms(1);
    LCD_PORT |= _BV(LCD_RST_PIN);
    // Set LCD CE pin to 1 (Disabled)
    LCD_PORT |= _BV(LCD_CE_PIN);
	// LCD Controller initialization
    LCD_Send(LCD_CMD,0x21); // LCD Extended Commands
    LCD_Send(LCD_CMD,0xC8); // Set LCD Vop (Contrast)
    LCD_Send(LCD_CMD,0x06); // Set Temp coefficent
    LCD_Send(LCD_CMD,0x13); // LCD bias mode 1:48
    LCD_Send(LCD_CMD,0x20); // LCD Standard Commands,Horizontal addressing mode
    LCD_Send(LCD_CMD,0x0C); // LCD in normal mode
    // Clear LCD Cache
    memset(LcdCache,0x00,LCD_CACHE_SIZE);
	//Clear LCD Device
	LCD_Send(LCD_CMD, 0x80);
    LCD_Send(LCD_CMD, 0x40);
	for(int n=0; n<(LCD_REAL_X_RES*LCD_REAL_Y_RES); n++)
		LCD_Send(LCD_DATA,0x00);
}

// Move text cursor to X,Y coordinates
void LCD_GotoXY(unsigned char x, unsigned char y){
    // Boundary check!
    if(x>((LCD_VISIBLE_X_RES/6)-1)) return;
    if(y>((LCD_VISIBLE_Y_RES/8)-1)) return;
    // Calculate index. It is defined as address within LcdCache
    LcdCacheIdx = ( x * 6) + ( y * LCD_VISIBLE_X_RES);
}

// Displays a character at current cursor location and increment cursor location.
void LCD_Chr (unsigned char ch){
    unsigned char i;
	// Convert to a printable character.
    if ((ch<0x20)||(ch>0x7b)) ch = 92;
	// Copy lookup table from Flash ROM to LcdCache
	for (i=0; i<5; i++) LcdCache[LcdCacheIdx++]=pgm_read_byte(&(FontLookup[ch-32][i]))<<1;
	// Horizontal gap between characters
    LcdCache[LcdCacheIdx]=0x00;
    // At index number LCD_CACHE_SIZE - 1, wrap to 0
    if(LcdCacheIdx==(LCD_CACHE_SIZE-1)){
        LcdCacheIdx = 0;
	} else {
		// Otherwise just increment the index
		LcdCacheIdx++;
	}
}

// Displays a string at current cursor location and increment
// cursor location. This function is dedicated to print string
// laid in SRAM
void LCD_Str(unsigned char dataArray[]){
    unsigned char tmpIdx=0;
    while(dataArray[tmpIdx]!='') LCD_Chr(dataArray[tmpIdx++]);
}

// Displays a string at current cursor location and increment
// cursor location. This function is dedicated to print string
// laid in Flash ROM
void LCD_FStr(const unsigned char *dataPtr){
    unsigned char c;
    for (c=pgm_read_byte(dataPtr); c; ++dataPtr, c=pgm_read_byte(dataPtr)) LCD_Chr(c);
}

// Displays a pixel at given absolute (x, y) location.
unsigned char LCD_Pixel(unsigned char x, unsigned char y, LcdPixelMode mode ){
    unsigned int index;
    unsigned char offset;
    unsigned char data;

    // Prevent from getting out of border
    if (x > (LCD_VISIBLE_X_RES-1)) return OUT_OF_BORDER;
    if (y > (LCD_VISIBLE_Y_RES-1)) return OUT_OF_BORDER;
    // Recalculating index and offset
    index=((y/8)*LCD_VISIBLE_X_RES)+x;
    offset=y-((y/8)*8);
    // Bit processing
    data=LcdCache[index];
    if (mode==PIXEL_ON) data |= (0x01< dy )
    {
        // Take fraction
        fraction = dy - ( dx >> 1);
        while ( x1 != x2 )
        {
            if ( fraction >= 0 )
            {
                y1 += stepy;
                fraction -= dx;
            }
            x1 += stepx;
            fraction += dy;

            // Draw calculated point
            response = LCD_Pixel( x1, y1, mode );
            if(response) return;
        }
    }
    else
    {
        // Take fraction
        fraction = dx - ( dy >> 1);
        while ( y1 != y2 )
        {
            if ( fraction >= 0 )
            {
                x1 += stepx;
                fraction -= dy;
            }
            y1 += stepy;
            fraction += dx;
            // Draw calculated point
            response = LCD_Pixel( x1, y1, mode );
            if(response) return;
        }
    }
}

// Dump chache to LCD
void LCD_Update(void){
	unsigned int i=0;
	for (unsigned char row=0; row<(LCD_VISIBLE_Y_RES / 8); row++){
		LCD_Send(LCD_CMD, 0x80);
		LCD_Send(LCD_CMD, 0x40 | row);
		for (unsigned char col=0; col

Yazar: gevv

Yazarımızın 320volt.com Blog üzerinde şu an okuduğunuz yazı dahil 1959 yazısı bulunmaktadır. Yazarımız hakkında bilgileri ve diğer yazılarını görmek için bakınız;

Elektronik

Yorum yapın

Doğrulama: (kutuyu işaretleyiniz)

  • Lütfen Türkçe imla kurallarına dikkat etmeye özen gösteriniz.
  • Yorumunuz yönetici tarafından kontrol edilmeden yayımlanmaz.
  • Paylaşılan devrelerin malzeme listesini istemeyiniz. Olsa zaten paylaşılırdı şema üzerinden listeyi çıkartabilirsiniz
  • Gavatar sitesine avatarınızı yükleyebilirsiniz.