spacer.png, 0 kB

Torna indietro   Roboitalia.com - Il primo portale in Italia sulla robotica amatoriale > Robotica di base > Informatica > P. in Assembler

Rispondi
 
Strumenti discussione Modalitą  visualizzazioe
  #11  
Vecchio 06-08-2012, 10.25.10
MaryFrą MaryFrą non ĆØ collegato
Nuovo robottaro
 
Data registrazione: 19-06-2012
Residenza: sicilia
Etą : 31
Messaggi: 2
Potenza reputazione: 0
MaryFrą E' per ora ancora un mistero
Predefinito help !!

Good morning. I am a italian student and i'm working with a display in my project. I try this program :


#include "io430.h"
//<msp430f5437A.h>

// LCD Port assignement
#define LCD_DIR P4DIR
#define LCD_OUT P4OUT

// Lcd Pin assignement
#define LCD_PIN_RS BIT4
//#define LCD_PIN_RW BIT7 connesso a GND
#define LCD_PIN_EN BIT5
#define LCD_PIN_D4 BIT0
#define LCD_PIN_D5 BIT1
#define LCD_PIN_D6 BIT2
#define LCD_PIN_D7 BIT3

// Procedure to strobe data to LCD register
void LCDPulseEN(void)
{ // Set Enable active
__delay_cycles(20);
LCD_OUT |= LCD_PIN_EN;
__delay_cycles(20);
// Release Strobe
LCD_OUT &= (~LCD_PIN_EN);
}

// this send 4 bit of data
void SendNibble(char data)
{
// Clear all data bit
LCD_OUT &= ~(LCD_PIN_D4|LCD_PIN_D5|LCD_PIN_D6|LCD_PIN_D7);
// Set data bit on port bit
if(data & 0x01)
LCD_OUT |= LCD_PIN_D4;
if(data & 0x02)
LCD_OUT |= LCD_PIN_D5;
if(data & 0x04)
LCD_OUT |= LCD_PIN_D6;
if(data & 0x08)
LCD_OUT |= LCD_PIN_D7;
// Nibble set complete, send to LCD
LCDPulseEN();
__delay_cycles(500);
}

// Send a byte of data to LCD register
void SendByte(unsigned char data)
{
SendNibble((data>>4) & 0x0F);
SendNibble((data) & 0x0F);
__delay_cycles(500);
}

// send a byte to command register
void SendInstruction(unsigned char data)
{
// Set Register to command
LCD_OUT &= ~LCD_PIN_RS;
SendByte(data);
__delay_cycles(80000);
}

// Send a byte of data to LCD register
void LCDputch(unsigned char data)
{
// Set Register to data
LCD_OUT |= LCD_PIN_RS;
SendByte(data);
__delay_cycles(500);
}



void InitLCD(void)
{
// clear all bit of LCD control & data Lines
LCD_OUT &= ~(LCD_PIN_EN|LCD_PIN_RS); //|LCD_PIN_RW);
// Set LCD pins to output
LCD_DIR |=(LCD_PIN_EN|LCD_PIN_RS|LCD_PIN_D4|LCD_PIN_D5|LCD _PIN_D6|LCD_PIN_D7); // |LCD_PIN_RW
// wait Powerup
__delay_cycles(100000);
// LCD can be in an unknown state so set to a known state sending 3 times LCD set to 8 bit mode
SendNibble(3);
__delay_cycles(16000); // Wait for init
SendNibble(3);
__delay_cycles(400);
SendNibble(3);
__delay_cycles(400);
// now is 8 bit, sending 2 set mode to 4 bit (0x2n)
SendNibble(2);
__delay_cycles(800);
// Now set to mode 4 bit 2 line 5x7 char
SendInstruction(0x28);
__delay_cycles(8000);
// Make cursor visible one line set to 0x0c to invisible cursor
SendInstruction(0x0e);//c
__delay_cycles(800);
// Clear screen
SendInstruction(0x01);
__delay_cycles(8000);
// Increment address mode
SendInstruction(0x06);
__delay_cycles(8000);
// Set write data address to 0
SendInstruction(0x80);
}

// Set write cursor to Row and Col
void LCDSetPosition(char Row, char Col)
{
// if row is not 0 add 0x40 (4 line models require adding 0 20 60 40)
if(Row)
Col+=0x40;
SendInstruction(0x80 | Col);
__delay_cycles(800);
}

// Clear LCD
void LCDClear(void)
{
SendInstruction(0x01);
__delay_cycles(100000);
}

// Lcd cursor to first row first column
void LCDGoToHome(void)
{
SendInstruction(0x02);
__delay_cycles(100000);
}

// Shift left mode
void LCDShiftLeft(void)
{
SendInstruction(0x18);
}

// Shift right mode
void LCDShiftRight(void)
{
SendInstruction(0x1C);
}

// Cursor blinking mode
void LCDBlinkCursor(void)
{
SendInstruction(0x0F);
}

// Print a text line to LCD screen
void LCDPrintString(const char * Text)
{
while (*Text)
LCDputch(*Text++);
}

void main (void)
{
// char c;
// int i;
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;

InitLCD();
LCDPrintString("Hello world");
// c='0';
// while(1)
// {
// LCDSetPosition(1,10);
// for(i=0;i<100;i++)
// __delay_cycles(1000);
// LCDputch(c);
// c++;
// if(c>'9') c='0';
// }
}

and it works. I have to translate this program in assembly language, you can help me? I am desperate because i try to do this program from 3 weeks and I did not succeed. I use MSP430F5437A.Thank you very much.
Rispondi citando
Rispondi


Utenti attualmente attivi che stanno leggendo questa discussione: 1 (0 utenti e 1 ospiti)
 
Strumenti discussione
Modalitą  visualizzazioe

Regole di scrittura
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code č Attivato
Le smilies sono Attivato
[IMG] č Attivato
Il codice HTML č Disattivato

Vai al forum

Discussioni simili
Discussione Autore discussione Forum Risposte Ultimo messaggio
Aiuto, esercizio Arduino saw_ana Arduino 5 12-12-2012 21.24.29
Esercizio assembler MaryFrą P. in Assembler 1 19-06-2012 21.08.14
Esercizio amplificatore roby006 E. Analogica 2 31-03-2012 13.51.31
esercizio assembler dott P. in Assembler 2 10-06-2007 18.42.38
Altro esercizio assembler piccolastella P. in Assembler 3 01-06-2003 07.45.03


Tutti gli orari sono GMT. Adesso sono le: 02.41.47.


Basato su: vBulletin Versione 3.8.8
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Realizzazione siti web Cobaltica Foligno
spacer.png, 0 kB