CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

VFD display(Model GU140x32F-7000)

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
zach.schneider



Joined: 09 Feb 2009
Posts: 1
Location: NDSU

View user's profile Send private message

VFD display(Model GU140x32F-7000)
PostPosted: Mon Feb 09, 2009 3:33 pm     Reply with quote

We are trying to run a VFD display using a max232 and a pic16f876a micro and we are using MPLAB to write the C code to run our display. Could anyone help us with the code ? This is what we got so far.
Code:

// Global Variables

unsigned int  Counter1;   // total pulses counted so far
unsigned int  Counter2;   // # of TMR2 interrupts seen
unsigned int  SPEED;      // # egdes / 100ms (100*rev/sec)
unsigned int  REF;        // desired speed (100*rev/sec)


bank1 unsigned char MSG[10];     // sci message coming in
bank1 unsigned char MSG_LENGTH;  // length of message
bank1 unsigned char TEMP;        // temp variable
bank1 unsigned char N;           // temp length of message
bank1 unsigned char FLAG;        // 1 means carriage return seen

const unsigned char MSG0[10] = "Hope";
const unsigned char MSG1[10] = "Courage";
const unsigned char MSG2[10] = "LOVE";
const unsigned char MSG3[10] = "TIME";



// Subroutine Declarations
#include   <pic.h>

static volatile unsigned int Timer1 @ 0x0E;
static volatile unsigned int Capture1 @ 0x15;


#include        "lcd_20x4.h"
#include        "function.h"
#include        "a2d.h"



// Subroutines
#include        "lcd_20x4.c"
#include        "function.c"
#include        "bootloader.c"
#include        "a2d.c"


// Interrupt service routine


void interrupt IntServe(void) @ 0x10
{
   if (RCIF) {
      RC0 = !RC0;    // debug info for RCIF interrupts
      TEMP = RCREG;
      while(!TRMT); TXREG = TEMP;
      MSG[N] = TEMP;
      N += 1;
      if (N > 9) N = 9;
      if (TEMP == 13) {
         FLAG = 1;
         MSG_LENGTH = N;
         N = 0;
         }

      RCIF = 0;
      }
   if (INTF) {
      RC1 = !RC1;    // debug I/O for INT interrupts
      Counter1 += 1;
      INTEDG = !INTEDG;

      INTF = 0;
      }
   if (TMR2IF) {
      RC3 = !RC3;    // debug I/O for TMR2 interrupts
      Counter2 += 1;
      if (Counter2 > 9) {   // every 100ms...
         SPEED = Counter1;
         Counter1 = 0;
         Counter2 = 0;
         RC4 = !RC4;
         }
      TMR2IF = 0;
      }
   if (TMR1IF) {
      RC2 = 1;
      TMR1IF = 0;
      }
   if (CCP1IF) {
      RC2 = 0;
      CCP1IF = 0;
      }
   }

void SCI_Out(unsigned int Data)
{
   unsigned char A[5];
   unsigned char i;

   for (i=0; i<5; i++) {
      A[i] = Data % 10;
      Data = Data / 10;
      }


//   for (i=0; i<15; i++) {
//      while(!TRMT);  TXREG = '0' + i;     // '0' = 48
//   }
   for (i=0; i<15; i++) {
      while(!TRMT);  TXREG = MSG2[i];     // '0' = 48
   }

   }

// Main Routine

void main(void)
{
   unsigned char i;
   unsigned int A2D;
   unsigned char A[5];

   TRISB  = 0x00;               
   TRISC  = 0x00;
   TRISA  = 0x00;
   ADCON1 = 6;

   PORTC = 0;
   PORTB = 0;
   PORTA = 0;

   FLAG = 0;

   Wait_ms(100);

// Initialize Serial Port
   TRISC = TRISC | 0xC0;
   TXSTA = 0x22;           // 8-bit no parity
   RCSTA = 0x90;           // continuous receive
   TXIE  = 0;              // no interrupt on xmit
   RCIE  = 1;              // no interrupt on receive
   BRGH  = 1;
   SPBRG = 31.5;             // 38400 changed to 31.5
   SYNC  = 0;

// initialize INT interrupts
   INTE = 1;
   INTEDG = 1;

// initialize Timer2 interrupts for 10ms
    T2CON  = 0x77;
    PR2    = 207;
    TMR2IE = 1;
    PEIE   = 1;

// Initialize Timer1.  When Timer1 = 0, set RC2.
   T1CON  = 0;
   TMR1CS = 0;
   TMR1ON = 1;
   TMR1IE = 1;

// Initialize Timer1 Capture.  When Timer1 = Capture1, clear RC2
   CCP1CON = 0x0A;
   CCP1IE = 1;
   TRISC2 = 0;
   A2D_Init();
   GIE     = 1;
   REF = 0;
   Capture1 = 100;

      REF = A2D_Read(0);
      Capture1 += (REF - SPEED);
      SCI_Out(REF);
      SCI_Out(Capture1);
      SCI_Out(SPEED);
      while(!TRMT); TXREG = 13;   // carriage return
      while(!TRMT); TXREG = 10;   // line feed


      }


      }

This will write "LOVEtCourLOVE?" scrolling and over again to our Display. Which I believe tells us two things we have the correct Baud rate coming out from our pic and we have connections right. We wanted to figure out how to right code that goes where we want it and stops repeating. Also if it makes sense would help.

Thanks any help is appreciated.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Feb 09, 2009 4:11 pm     Reply with quote

Are you using the CCS compiler ? This is not CCS code. It's pseudo-ASM
code, written for some C compiler.

Here's the full manual for the VFD display:
http://www.elektroncso.hu/cikkek/gu140x32f-7000_e04.pdf
Look on page 8 for the serial interface specification. You need to write
a serial transmit function that will poll the SBUSY bit, and wait until the
VFD can accept a byte. Then use the putc() function to send a byte to
the VFD.

There are jumper selections on page 29 of the VFD data sheet, which
show how to configure the baud rate.

You may have to send an initial reset pulse after power-up and wait for
the specified time before sending data to the VFD.

You can use the CCS serial port library code, which is invoked with the
#use rs232() statement. It may or may not be RS-232 levels (it might
be TTL levels, non-inverted). You need to determine that.

I don't want to do this for you. You need to study the CCS compiler
manual (if you have the compiler) and do it yourself.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group