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 CCS Technical Support

speqakjet IC with PIC

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



Joined: 06 Nov 2012
Posts: 29

View user's profile Send private message

speqakjet IC with PIC
PostPosted: Sun Feb 10, 2013 11:41 pm     Reply with quote

hi
I'm doing project with speak jet ic in order to speak the content what I'm giving from controller. I have got sample code, but it is in Mikro Pro compiler, in that they have included many header files. But I don't know how to change it for ccs compiler, can anybody help me to do my project ? Here is the code:
main code:
Code:

#include <18f4685.h>
//#include <delay.h>
#include <Init_PICMicro.h>
#include <Speakjet_Serial.h>
#include <phonemes.h>
#include <phrases.h>

// SpeakjetTest.c
// Uses P18F4685PIC Micro @8Mhz.  This program is written for the EasyPIC5
// Development Board.
// Speakjet controller on PORTD.
// PORTA pulled high.
// PORTA.RA0 = Speak PB
// PORTA.RA1 = Reset PB
// LCD on PORTB
// Change Speakjet Port assignments in "Speakjet_Serial.h" file.
// Uses Soft_Uart_Init to send serial data to speakjet.

//RC Irace
//6.13.2011
//****************************************************************************
// LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;

sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections
//****************************************************************************
//Variable Declarations
//                      12345678901234567890
char Message1[]= "Speakjet   Test ";
char Message2[]= "for P18F4685    ";
char Message3[]= "                ";
char Message4[]= "RA0 to speak....";
char Message8[]= "Transmitting....";
char num[4];
char toggle;
int k;
const char _welcome[] = {_pitchx, 118, 185, 131, 145, 4, 195, 136, 140, 0};
const char _to[] = {_pitchx, 80, 192, 162, 0};
const char _the[] = {_pitchx, 80, 169, 134, 0};
const char _speakjet[] = {_pitchx, 108, 187, 198, 128, 194, 4, 165, 131, 191, 0};
const char _test[] = {_pitchx, 98, 191, 131, 187, 191, 0};
const char _program[] = {_pitchx, 88, 199, 148, 137, 179, 148, 132, 140, 0};

//****************************************************************************
void main()
{
  Init_PICMicro();
  Reset_Speakjet();
//***************************************************************************
  LCD_Out(1, 1, Message1);
  LCD_Out(2, 1, Message2);
  Delay2000ms();
  LCD_Out(2, 1, Message4);
  toggle = 1;
//***************************************************************************
while (1==1)
{
// ***Button Scanner *******************************************************
  if (PORTA.F0 == 0)
     {
     while (PORTA.F0 == 0)    //  Press to speak phrases
        {
        }
     toggle = toggle ^ 1;
     }
  if (PORTA.F1 == 0)        // Press to Reset,  says "Ready"
     {
     while (PORTA.F1 == 0)
        {
        }
     Reset_Speakjet();
     }
// ***Speech Phrases*********************************************************
  if (toggle == 0)
    {
    LCD_Out(2, 1, Message8);
    Speakjet_Serial(_welcome);
    Speakjet_Serial(_to);
    Speakjet_Serial(_the);
    Speakjet_Serial(_speakjet);
    Speakjet_Serial(_test);
    Speakjet_Serial(_program);
    Delay1000ms();
    Speakjet_Serial(_one);
    Delay1000ms();
    Speakjet_Serial(_two);
    Delay1000ms();
    Speakjet_Serial(_three);
    Delay1000ms();
    Speakjet_Serial(_four);
    Delay1000ms();
    Speakjet_Serial(_five);
    Delay1000ms();
    Speakjet_Serial(_goodbye);
    toggle = 1;
    LCD_Out(2, 1, Message4);
    }

header file:
Code:

void Speakjet_Serial(const char s[])
{
        unsigned char i;

        for (i = 0; s[i] != 0; i++)
          {
    Soft_Uart_Write(s[i]);     // Sends Character Data
    while (speaking == 1)      // If Speakjet already speaking, wait
        {
        }
    Delay10ms();
          }
          return;
} // End Speakjet_Serial

//***********************************************************void Reset_Speakjet()
{
    RST = 1;
    Delay100ms();
    RST = 0;
    Delay100ms();
    RST = 1;
    Delay100ms();
    return;
}

//----------------
void Init_PICMicro()
{
#define ready    PORTD.F0
#define speaking PORTD.F1
#define RST      PORTD.F2
#define WP       2

         //  76543210
  CMCON  = 0b00000111;
  ADCON1 = 0b00001111;
  TRISA  = 0b00001111;
  TRISB  = 0b00000000;
  TRISC  = 0b10000000;
  TRISD  = 0b00000011;
  TRISE  = 0b00000111;
  Lcd_Init();                 // Initialize LCD EasyPIC5
  LCD_Cmd(_LCD_CLEAR);        // Clear display
  LCD_Cmd(_LCD_CURSOR_OFF);   // Turn cursor off
//Soft_Uart_Init(port, rx, tx, baud_rate, inverted);
  Soft_Uart_Init(&PORTD, 7, 6, 9600, 0);
}
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