Ejemplo n.º 1
0
Archivo: lcd.c Proyecto: tyrielv/Organ
void initLCD(void) {
    // PMP initialization
    mPMPOpen(PMP_ON | PMP_READ_WRITE_EN | 3,
            PMP_DATA_BUS_8 | PMP_MODE_MASTER1 |
            PMP_WAIT_BEG_4 | PMP_WAIT_MID_15 |
            PMP_WAIT_END_4,
            0x0001,         // only PMA0 enabled
            PMP_INT_OFF);   // no interrupts used
    // wait for >30ms
    delayTimer1(9375);
    
    //initiate the HD44780 display 8-bit init sequence
    PMPSetAddress(LCDCMD);  // select command register
    PMPMasterWrite(0x38);   // 8-bit int, 2 lines, 5x7
    delayTimer1(15);
    
    PMPMasterWrite(0x0c);   // ON, no cursor, no blink
    delayTimer1(15);
    
    PMPMasterWrite(0x01);   // clear display
    delayTimer1(563);
    
    PMPMasterWrite(0x06);   // increment cursor, no shift
    delayTimer1(563);
    
}
/*********************************************************************
 * Function:       
 *
 * PreCondition:    
 *
 * Input:           
 *
 * Output:          
 *
 * Side Effects:    
 *
 * Overview:        
 *
 * Note:           
 ********************************************************************/
inline void __attribute__((always_inline)) Ex16LCDCmd(BYTE cmd, UINT wait)
{
	PMPSetAddress(0x0000);
	PMPMasterWrite(cmd);
    MSTimerWait(wait);                
  
}
Ejemplo n.º 3
0
void PMP_Write(CPU_INT16U address, CPU_INT08U data)
{
#ifdef _TARGET_440H
#else
	PMPSetAddress(address);
    PMPMasterWrite(data);
#endif
}
Ejemplo n.º 4
0
CPU_INT08U PMP_Read(CPU_INT16U address)
{
#ifdef _TARGET_440H
#else
	CPU_INT08U value;
	PMPSetAddress(address);
	PMPMasterRead(); // Read the previous value and start a read operation onto PMP
    value = mPMPMasterReadByte(); // Read the actual latched value
	return value;
#endif
}
/*********************************************************************
 * Function:       
 *
 * PreCondition:    
 *
 * Input:           
 *
 * Output:          
 *
 * Side Effects:    
 *
 * Overview:        
 *
 * Note:           
 ********************************************************************/
inline BYTE __attribute__((always_inline)) Ex16LCDGetChar(void)
{
    BYTE data;

    PMPSetAddress(0x0001);
	data = PMPMasterRead();
    MSTimerWait(2);                // wait 1ms

    return data;

}
Ejemplo n.º 6
0
static void InitializeSystem(void)
{
    AD1PCFG = 0xFFFF;   
    SYSTEMConfigPerformance(80000000);
    UserInit();
    USBDeviceInit();	// Initializes USB module SFRs and firmware
    			// variables to known states.
    ConfigINT0(EXT_INT_PRI_6 | RISING_EDGE_INT | EXT_INT_ENABLE);
    
    mPMPOpen(PMP_CONTROL, PMP_MODE, PMP_PORT, PMP_INT);
    PMPSetAddress(0x4000);
}
Ejemplo n.º 7
0
//Writes byte to selected page
void lcdWrite(uint8_t page, uint8_t column)
{
   	// make sure column and page are within bounds
   	page %= 9;
   	column %= 128;
   	
	// set column  MSB
	lcdCommand(0x10 | ((127 - column) >> 4));
	// set column LSB
	lcdCommand(0x0F & (127 - column));
	
	// set page
	lcdCommand(0xB0 |(0x0F & (7-page)));
	
    //Data write
    PMPSetAddress(1); 
    PMPMasterWrite( display[page][column] ); //Reverse Vertical Axis
}
Ejemplo n.º 8
0
// LCD initialization sequence
void initializeLCD(void) {
    mPMPOpen(CONTROL, MODE, PORT, INTERRUPT); // Initialize PMP using above settings
   // PMCON = 0x83BF; // Enable the PMP, long waits
    //PMMODE = 0x3FF; // Master Mode 1
    //PMAEN = 0x0001; // PMA0 enabled
    
    OpenTimer1(CONFIG, PERIOD); // Enable Timer 1
    Delay_ms(30); // LCD needs 30ms to power on, perform startup functions, etc

    PMPSetAddress(CMDREG); // Access the LCD command register
    PMPMasterWrite(0x38); // LCD Function Set - 8-bit interface, 2 lines, 5*7 Pixels
    Delay_ms(1); // Needs a 40us delay to complete

    PMPMasterWrite(0x0C); // Turn on display (with cursor hidden)
    Delay_ms(1); // Needs a 40us delay to complete

    PMPMasterWrite(0x01); // Clear the display
    Delay_ms(2); // Needs a 1.64ms delay to complete

    PMPMasterWrite(0x06); // Set text entry mode - auto increment, no shift
    Delay_ms(1); // Needs a 40us delay to complete
}
/*********************************************************************
 * Function:       
 *
 * PreCondition:    
 *
 * Input:           
 *
 * Output:          
 *
 * Side Effects:    
 *
 * Overview:        
 *
 * Note:           
 ********************************************************************/
inline void __attribute__((always_inline)) Ex16LCDPutChar(BYTE data)
{
    PMPSetAddress(0x0001);
	PMPMasterWrite(data);
    MSTimerWait(2);                // wait 1ms
}
Ejemplo n.º 10
0
Archivo: lcd.c Proyecto: Eclo/FreeRTOS
static void prvLCDData( char cChar )
{
	PMPSetAddress( LCD_DATA_ADDRESS );
	PMPMasterWrite( cChar );
	vTaskDelay( lcdVERY_SHORT_DELAY );
}
Ejemplo n.º 11
0
Archivo: lcd.c Proyecto: Eclo/FreeRTOS
static void prvLCDCommand( char cCommand ) 
{
	PMPSetAddress( LCD_COMMAND_ADDRESS );
	PMPMasterWrite( cCommand );
   	vTaskDelay( lcdSHORT_DELAY );
}
Ejemplo n.º 12
0
// Write a byte of data to either of the two LCD registers (DATAREG, CMDREG)
void writeToLCD(int reg, char c) {
    Delay_ms(1); // 40us needed in between each character write
    PMPSetAddress(reg); // Select either 'DATAREG' or 'CMDREG'
    PMPMasterWrite(c); // Write the byte to selected register
}
Ejemplo n.º 13
0
Archivo: lcd.c Proyecto: tyrielv/Organ
void writeLCD(int addr, char c) {
    while (busyLCD());      // wait for LCD ready
    PMPSetAddress(addr);    // select register
    PMPMasterWrite(c);      // init write sequence
}
Ejemplo n.º 14
0
Archivo: lcd.c Proyecto: tyrielv/Organ
char readLCD(int addr) {
    PMPSetAddress(addr);    // select register
    mPMPMasterReadByte();   // init read sequence
    return mPMPMasterReadByte();    // read actual data
}
Ejemplo n.º 15
0
int main(void)
{
	int	ix;
	int	errCnt=0;
	int	dmaChn=0;		// the DMA channel to use


	// Configure the device for maximum performance but do not change the PBDIV
	// Given the options, this function will change the flash wait states, RAM
	// wait state and enable prefetch cache but will not change the PBDIV.
	// The PBDIV value is already set via the pragma FPBDIV option above..
	SYSTEMConfig(SYS_FREQ, SYS_CFG_WAIT_STATES | SYS_CFG_PCACHE);

	// init the pseudo-random generator
	srand(ReadCoreTimer());

	// fill the bufffers with some random data
	for(ix=0; ix<sizeof(srcBuff); ix++)
	{
		srcBuff[ix]=rand();
		dstBuff[ix]=rand();
	}


	// setup the PMP
    	mPMPOpen(PMP_CONTROL, PMP_MODE,PMP_PORT_PINS ,PMP_INTERRUPT);

    	// setup the external memory device address
    	PMPSetAddress(PMP_EXT_ADDR);


	// Open the desired DMA channel. We use priority 0.
	DmaChnOpen(dmaChn, 0, DMA_OPEN_DEFAULT);

	// set the transfer event control: what event is to start the DMA transfer
	DmaChnSetEventControl(dmaChn, DMA_EV_START_IRQ(_PMP_IRQ));


	// set the transfer parameters: source & destination address, source & destination size, number of bytes per event
	DmaChnSetTxfer(dmaChn, srcBuff, (void*)&PMDIN, sizeof(srcBuff), 2, 2);


	// once we configured the DMA channel we can enable it
	// now it's ready and waiting for an event to occur...
	DmaChnEnable(dmaChn);
	// force the first transfer, the PMP is quiet
	DmaChnForceTxfer(dmaChn);


	// wait for the transfer to be completed
	while(!(DmaChnGetEvFlags(dmaChn)&DMA_EV_BLOCK_DONE))
	{
		
		// do some other useful work
	}

    	// setup the external memory device address
    	PMPSetAddress(PMP_EXT_ADDR);
	// flush the PMP data latches
	PMPMasterRead();

	// set the transfer parameters: source & destination address, source & destination size, number of bytes per event
	DmaChnSetTxfer(dmaChn, (void*)&PMDIN, dstBuff, 2, sizeof(dstBuff), 2);
	DmaChnEnable(dmaChn);
	DmaChnForceTxfer(dmaChn);

	// wait for the transfer to be completed
	while(!(DmaChnGetEvFlags(dmaChn)&DMA_EV_BLOCK_DONE))
	{
		// do some other useful work
	}

	// compare the transfer completed ok
	for(ix=0; ix<sizeof(srcBuff); ix++)
	{
		if(srcBuff[ix]!=dstBuff[ix])
		{
			errCnt++;
		}
	}

	// close the PMP
	mPMPClose();

	while(1);

	return errCnt;

}