UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Explorer
Explorer
9,924 Views
Registered: ‎12-06-2007

Re: Very Difficult , Need Aid:- FPGA Not Sending Out Data (UART Problem)

 

Good evening,

 

 

 

1)

 

Question 

I am sending One of the Pic of hyperterminal which you have sent with remarks as an attachment.

Red Line means the response from the modem and

Blue lines means the commands which you are sending from the PC - I mean you are typing

Pl confirm - is it so?

 

Answer

No. This is correct:-

 

xx ---------From PC (Trying to type AT)

ERROR----From Modem

AT

OK

AT + CMGF = 1

OK

AT + CMGS = "+60179310740"

> help me

 

+CMGS:79

 

 

OK

 

 

2)

 

Question

 

Every time you connect the modem with the PC do you get some msg at the initial stage - Like in this case xx and Error, before you start sending commands. (in the Pic 11b it is T and ERROR) - Pl confirm?

 

 

Answer

 

Yes, it always get 

 

a) hang (instead of AT, it might appear T only or does not appear anything. But when i press enter, it display ERROR)

 

T ---------From PC (Trying to type AT)

ERROR----From Modem (When press "Enter")

AT

OK

 

b) appear wrong input (instead of AT , it might appear xx, or @ or funny symbols. )

 

xx ---------From PC (Trying to type AT)

ERROR----From Modem (When press "Enter")

AT

OK

 

 

c)

 

Question

How to insert Pictures?

There is one icon for Insert/Edit Picture in the top - But when ever I click it it asks for Image URL. But how to insert image from PC? In your few many post you have inserted pictures - It'll be really helpful to me if you can let me know the way.

 

 

 

Answer

It is simple. Follow this steps:-

1) Download the attachment and go through.  

2) Click this http://imageshack.us/

3) Browse for the pic

4) Upload it  

5) Copy the link and insert in the Xilinx forum "Insert/Edit Image

6) Then press "insert". And look below where the cursor was pointing.

 

Hope it might help. I feel proud helping you .

 

If anything , please reply to me as soon as possible. Really hoping high for your guide. 

 

Thank you very much.

0 Kudos
Explorer
Explorer
9,902 Views
Registered: ‎12-06-2007

Re: Very Difficult , Need Aid:- FPGA Not Sending Out Data (UART Problem)

Good evening,

 

  Do you have any progress? If you have anything you want me do , please let  me know.

  

Thank you.

0 Kudos
Explorer
Explorer
9,898 Views
Registered: ‎04-06-2009

Re: Very Difficult , Need Aid:- FPGA Not Sending Out Data (UART Problem)

I went through the User guide of the Modem. By default the Autobauding is enabled in the Modem, hence initially you have to syncronize the serila communication in between the Modem and FPGA. For syncronizing you have to send "AT" from the FPGA and to check the received byte. You have to keep on sending "AT" untill and unless you dont get back "AT" in your received packet.

I have made some changes in the file "TestApp_Peripheral.c" to incorporate the syncronization. Use this file and try out - I hope it should work. Pl find the file as an attachment.

 

Best of Luck! 

Shantanu

Shantanu Sarkar
http://www.linkedin.com/pub/shantanu-sarkar/0/33a/335
0 Kudos
Explorer
Explorer
9,897 Views
Registered: ‎04-06-2009

Re: Very Difficult , Need Aid:- FPGA Not Sending Out Data (UART Problem)

I have highlited some part related to UART in the user guide of the modem. Pl go through it. In the documents you have sent related to Modem I failed to find pin details of the RS232 connector. Pl communicate with the vendor to send the details so that you can cross check it.

 

After carrying out the experiment please let me know the status.

 

Shantanu

 

Shantanu Sarkar
http://www.linkedin.com/pub/shantanu-sarkar/0/33a/335
0 Kudos
Explorer
Explorer
9,874 Views
Registered: ‎04-06-2009

Re: Very Difficult , Need Aid:- FPGA Not Sending Out Data (UART Problem)

Any updates?

From 14th to 17th I'll be out of station.

Shantanu

Shantanu Sarkar
http://www.linkedin.com/pub/shantanu-sarkar/0/33a/335
0 Kudos
Explorer
Explorer
9,828 Views
Registered: ‎12-06-2007

Re: Very Difficult , Need Aid:- FPGA Not Sending Out Data (UART Problem)

Good evening,

 

   Thank you for replying. There are some questions I need to verify from you (it is in color blue).

 

1)

 

You have to keep on sending "AT" untill and unless you dont get back "AT" in your received packet.

=> When I press the PB , I can not see another "AT" at the Hyperterminal. So how can I repeatedly send "AT" ?

 

2)

I have made some changes in the file "TestApp_Peripheral.c" to incorporate the syncronization. Use this file and try out - I hope it should work.

=> Do I need to change anything on the code?

 

A) 

It is because everytime I press the PB for the first time, it will appear

 

Starting New

AT

 

I tried to delete the Starting New , but I can not find it in the attachment C coding (you gave). Should I ignore it ?

 

B)

The modem will only commucate corectly if the syntax is correct. In the line 235 you wrote

 

status = Send_Command_To_Modem("+60179310740");  

 

but it should be

 

status = Send_Command_To_Modem(" \"+60179310740\" ");  

 

Below is the proper syntax. If not , it will give error. 

AT

AT+CMGF= 1

AT+CMGS= "+60179310740"

 

If I change it , would it ignore "cannot send more than 16 bytes at a time " principle?

 

 

 3)

Pl go through it. In the documents you have sent related to Modem I failed to find pin details of the RS232 connector. Pl communicate with the vendor to send the details so that you can cross check it.

=> I had emailed the vendor , and this what he replied:-

 

I do not  have the datasheet for RS232 connector, but your can use  PC to communicate with your FPGA- Modem, is still can not communicate, cross  pin 2 and pin 3 (RS232) try  communicate with your PC again.If still can not, that means your FPGA modem problem.

4)

Any updates? From 14th to 17th I'll be out of station.

=>Once you online, please reply to me as soon as possible. When you were out station , I read your code and the document you told me to read.  But I still need your confirmation , before I can test it.

 

 

Thank you. 

 

0 Kudos
Explorer
Explorer
9,810 Views
Registered: ‎12-06-2007

Re: Very Difficult , Need Aid:- FPGA Not Sending Out Data (UART Problem)

Good evening,

 

 

    In the attachment, there are diagrams that I have done.I had used the new TestApp_Peripheral.c. Please go through it . I have a problem :-

 

1)

 

Starting New // Where this came from? I read many times, and I still can not find it . I am not sure whether my PC got virus or not.

AT

AT+CMGF=1

AT+CMGS=+60179310740 // It should be AT+CMGS="+60179310740" . I had changed it in the program, but it still won't change in the Hyperterminal

 

 

 

 

 

Please reply to me as soon as possible .

 

 

 

Thank you very much.

 

 

0 Kudos
Explorer
Explorer
9,807 Views
Registered: ‎04-06-2009

Re: Very Difficult , Need Aid:- FPGA Not Sending Out Data (UART Problem)


 

1)

 

You have to keep on sending "AT" untill and unless you dont get back "AT" in your received packet.

=> When I press the PB , I can not see another "AT" at the Hyperterminal. So how can I repeatedly send "AT" ?

 

In the following part I am taking care of that. For sending AT repeatedly for syncronization purpose you dont have to press PB.


 

 

//------------------------------------------------------------------------- do//Clear the RX Buffer as a initialization { Func_Delay(5); Temp32Bit = UartLite_Receive_Data(XPAR_RS232_DCE_DEVICE_ID); }while(Temp32Bit > 0); //------------------------------------------------------------------------- //For syncronization Send "AT\r" to Modem and check for "AT" in the Received byte //Repeat untill "AT" is not received. Clear_LCD(); Flag_Syncronize = 0; //Reset the Flag Send_PKT_to_LCD("Synchronizing...",1); //------------------------------------------------------------------------- do { Func_Delay(200); if((++LedBit)>= 0xFF)LedBit=0x00; status = Out_GPIO(XPAR_LEDS_DEVICE_ID, LedBit); Reset_Global_Buffer(); Send_PKT_to_LCD(" ",2); status = Send_Command_To_Modem("AT"); if (status != XST_SUCCESS) Disp_Failure_Msg(); //Display Failure Message in LCD status = Send_End_of_Text_to_RS232(XPAR_RS232_DCE_DEVICE_ID); if (status != XST_SUCCESS) Disp_Failure_Msg(); //Display Failure Message in LCD //May be here You have to put some delay before calling Get_Response_of_Command().

//But not now Get_Response_of_Command(); for(Index=0; Index < Global_RX_Buf_EndPTR; Index++) {if((Global_RX_Buffer[Index] == 'A') && (Global_RX_Buffer[Index+1] == 'T'))Flag_Syncronize = 1;} if(Flag_Syncronize > 0)break; }while(1); //------------------------------------------------------------------------- //Now ready to communicate..... Clear_LCD(); Send_PKT_to_LCD(&Global_RX_Buffer[0],2); Send_PKT_to_LCD("Ready",1); for(Index=0,LedBit=0x01; Index < 8; Index++) { Send_PKT_to_LCD(".",0); Func_Delay(200); status = Out_GPIO(XPAR_LEDS_DEVICE_ID, LedBit); LedBit=LedBit << 1; }


2)

I have made some changes in the file "TestApp_Peripheral.c" to incorporate the syncronization. Use this file and try out - I hope it should work.

=> Do I need to change anything on the code?

I hope no.  except  status = Send_Command_To_Modem("+60179310740");  



A) 

It is because everytime I press the PB for the first time, it will appear

 

Starting New

AT

 

I tried to delete the Starting New , but I can not find it in the attachment C coding (you gave). Should I ignore it ?

 

In the revised code I have already deleted the line which was sending Starting New - So you will not find it.

From your reply what I am understanding your code is not getting compiled. Clean the project first (Clean Netlist, Clean Bit, Clean Project) and then Generate all fresh with new code.

 

If still you are getting problem - better you make the project from the scratch with the new code you are having. Also Make sure that I have selected the right Macros as per xparameter.h. I have tested the Source code on prj made for Spartan3an Kit using hyperterminal - It was working fine.



B)

The modem will only commucate corectly if the syntax is correct. In the line 235 you wrote

 

status = Send_Command_To_Modem("+60179310740");  

 

but it should be

 

status = Send_Command_To_Modem(" \"+60179310740\" ");  

 

Below is the proper syntax. If not , it will give error. 

AT

AT+CMGF= 1

AT+CMGS= "+60179310740"

 

If I change it , would it ignore "cannot send more than 16 bytes at a time " principle?

 

"+60179310740" - 14 Bytes so you can go ahead. But I'll suggest initially keep the sw setting such that FPGA should send only "AT". Initially check out with "AT" command only - Once you are through then try out different commands.

 


 

Shantanu Sarkar
http://www.linkedin.com/pub/shantanu-sarkar/0/33a/335
0 Kudos
Explorer
Explorer
9,797 Views
Registered: ‎12-06-2007

Re: Very Difficult , Need Aid:- FPGA Not Sending Out Data (UART Problem)

Good evening,

 

  Thank you for replying. I had cleaned the project and then I have generated the netlist.

 

a) When I built it , this warning appear

 

/cygdrive/d/hati/ML401/TestApp_Peripheral/src/Code_Header/TestApp_Peripheral.c:70: warning: parameter names (without types) in function declaration
mb-size TestApp_Peripheral/executable.elf
   text    data     bss     dec     hex filename
   6412     664    4396   11472    2cd0 TestApp_Peripheral/executable.elf
Done!

 

b)When I clicked on download bitstream to the FPGA, this error appeared

 

ERROR: cannot open implementation/system.par: No such file or directory
make: *** [implementation/system.bit] Error 2
Done!

 

Questions

 

1) How can I solve this error? Do I need to add something or change something?

 

2) If the only way is doing it from the scratch , what do you mean this ? What should I be alert for ? 

 

"......Also Make sure that I have selected the right Macros as per xparameter.h. ...."

 

 Please reply as soon as possible .

 

Thank you very much.

 

 

 

 

0 Kudos
Explorer
Explorer
9,795 Views
Registered: ‎12-06-2007

Re: Very Difficult , Need Aid:- FPGA Not Sending Out Data (UART Problem)

Good evening,

 

   So sorry to trouble you. But can you help showing how you

 

=) Add the IP?

    It is because, I am still confuse how on earth you did it. It is because , in the sub-microblaze_0 (for example), there are TRACE, IXCL , DXCL..

 

 by Print Screen it and send it in diagram form. The rest I think I able to do it. Anything you want to inform me , you can tell me .

 

Please reply to me as soon as possible.

 

 

Thank you.

Tags (1)
0 Kudos
Explorer
Explorer
10,753 Views
Registered: ‎12-06-2007

Re: Very Difficult , Need Aid:- FPGA Not Sending Out Data (UART Problem)

 

    Good morning,

 

   

    So sorry to disturb you. I just able to embed in the FPGA using your program. I just cleaned it and then embeded it in the FPGA. If you have done the snapshot,please do send to me . I really want to see how you did it . If can not , it is fine with me. I understand that you sure have some other work to concentrate.

   I will do the FPGA-modem connection and the result I will inform you before Monday. I want to have a nap , because the all night I was awake.

 

   I have just have one question to ask you .

 

1) When I press the push button , the LCD display "synchronizing". When I send the Response.txt to the Hyperterminal , then only the FPGA LED will change light.

 

      =>  But if I connect to the Modem, I just need to push the PB once , and observe the LED light movement?

      =>  Is this status you want me to reply to you?

      =>  Is there any thing else that I should do (Your code is quite complex, I need time to study it throughly)?

 

 

   The FPGA-Modem connection, I have not tested yet. Once I have done it , I will notify you.

 

    I feel so bad pressuring you . If I had annoyed you , I am really sorry. Please do not get angry.

 

Thank you very much for you kind help. I really appreciate it .

 

 

Thank you.

0 Kudos
Explorer
Explorer
10,746 Views
Registered: ‎04-06-2009

Re: Very Difficult , Need Aid:- FPGA Not Sending Out Data (UART Problem)

 

Testing using Hyper terminal

Set the Dip Sw such that FPGA will only send “AT” Command – Best way set all '0' or all '1'

 

1> LCD displaying “Testing LCD Press any PB”

All LEDs will Glow indicates you need to press PB.

Press any PB

 

2> LCD displaying “Synchronizing...”

Hyper Terminal will receive “AT” and will be displayed in new line.

Send “Garbage.Txt” file - “xx\rError\r” - You can view “xx\rError\r” in the 2nd Line of the LCD for some fraction of time.

 

3> LCD will still display “Synchronizing...”

Hyper Terminal will receive “AT” once more and will be displayed in the next line.

Send “AT.Txt” file - “AT\r” - You can view “Ready...” in the 1st line and “AT\r” in the 2nd Line of the LCD for some fraction of time. Led will glow in shift wise.

 

4> LCD will still display “AT” in the 1st line

Hyper Terminal will receive “AT” once more and will be displayed in the next line.

Send “OK.Txt” file - “AT\rOK\r” - You can view “AT\rOK\r” in the 2nd Line of the LCD. All LEDs will Glow indicates you need to press PB.

Press any PB

 

5>Will go to step 4

 

 

Testing using Modem

Set the Dip Sw such that FPGA will only send “AT” Command – Best way set all '0' or all '1'

 

1> LCD displaying “Testing LCD Press any PB”

All LEDs will Glow indicates you need to press PB.

Press any PB

 

2> LCD displaying “Synchronizing...”

Keep watch on LCD until you find “Ready...” in the 1st line and “AT\r” in the 2nd Line of the LCD for some fraction of time. Led will glow in shift wise.

 

3> LCD will still display “AT” in the 1st line

Wait to view “AT\rOK\r” in the 2nd Line of the LCD. All LEDs will Glow indicates you need to press PB.

Press any PB

 

4>Will go to step 3.

 

Shantanu

 

Note: Pl find the different responses as attachment.

Shantanu Sarkar
http://www.linkedin.com/pub/shantanu-sarkar/0/33a/335
Tags (1)
0 Kudos
Explorer
Explorer
10,744 Views
Registered: ‎04-06-2009

Re: Very Difficult , Need Aid:- FPGA Not Sending Out Data (UART Problem)

I'll again not be avialable in the next week as I am going out of station on monday early morning and will be returning back on Sunday on official tour.

 

Shantanu

Shantanu Sarkar
http://www.linkedin.com/pub/shantanu-sarkar/0/33a/335
Tags (1)
0 Kudos
Explorer
Explorer
10,698 Views
Registered: ‎12-06-2007

Re: Very Difficult , Need Aid:- FPGA Not Sending Out Data (UART Problem)

Good morning,

 

     I did what you told me to do by using the straight-cable (as you recommended) . I did for 51 times. But it was not successful for FPGA-Modem connection . It stops at "Snychronizing...." with the first LED light up. The second line of the  LCD does not display anything. 

    Then I tried using ISE 9.2 to download the XPS 9.2 project to the FPGA to test the FPGA-Modem connection , but still unsuccessful.

     Next I tried changing the bits per second from 9600 to 115200 and tested it, but it still gave the same result . It stopped at "Snychronizing...." with the first LED light up.

    Using the straight-cable , I noticed modem LED does not light up. Then I used the crossed cable (just want to satisfy myself because I was nervous), I found the LED blinks continously for approximately every 2 seconds. But it also stopped at "Snychronizing...." with the first LED light up.

    What should I do next? 

 

     Please reply to me as soon as possible. 

 

 

Thank you.

0 Kudos
Explorer
Explorer
10,697 Views
Registered: ‎12-06-2007

Re: Very Difficult , Need Aid:- FPGA Not Sending Out Data (UART Problem)

Good morning

 

 "Then I used the crossed cable (just want to satisfy myself because I was nervous), I found the LED blinks continously for approximately every 2 seconds."

 

The LED I meant was from the Modem LED, NOT the FPGA LED. 

 

Thank you

0 Kudos
Explorer
Explorer
10,659 Views
Registered: ‎12-06-2007

Re: Very Difficult , Need Aid:- FPGA Not Sending Out Data (UART Problem)

Good morning

 

  So sorry to disturb you. The modem vendor emailed this 

 

" I do not  have the datasheet for RS232 connector, but your can use  PC to communicate with your FPGA- Modem, is still can not communicate, cross  pin 2 and pin 3 (RS232) try  communicate with your PC again. If still can not, that means your FPGA modem problem." 

 

  Fortunately , my lecturer was using this Board (SPARTAN-3A DSP 1800A Platform)

 

Description (Written on the board):-

 

SPARTAN

FGG676AGQO817

A3131253A

4C 

 

 

 

 

 

 This was your previous mail

 

" .....I am presently doing a design using EDK9.2 in Spartan3AN Starter Kit. I am comparing your code with mine.......I am sending one Project for your ML401 Kit, Pl find it as an attachment. I have tested the application part in different project done for Spartan3AN starter Kit (as I am not having ML401) and it seems working fine..."

 

   I am not sure whether Spartan3A and Spartan3AN is the same , but can you send me the code you have done so that I can embed and test it ? It would be very helpful for me.  I tried embedding , but I encountered errors .

 

    Please reply to me as soon as possible .

 

Thank you . Your help and guide is really being appreciated. 

 

 

Tags (1)
0 Kudos
Explorer
Explorer
10,659 Views
Registered: ‎12-06-2007

Re: Very Difficult , Need Aid:- FPGA Not Sending Out Data (UART Problem)

Good evening

 

 If using the Spartan , what cable should I use for

 

1) FPGA - PC connection ?

 

2) FPGA - Modem connection ?

 

 

 

Thank you.

0 Kudos
Explorer
Explorer
10,638 Views
Registered: ‎12-06-2007

Re: Very Difficult , Need Aid:- FPGA Not Sending Out Data (UART Problem)

Good morning,

 

 

    Modem Datasheet 

 

 

Thank you

0 Kudos
Explorer
Explorer
10,622 Views
Registered: ‎12-06-2007

Re: Very Difficult , Need Aid:- FPGA Not Sending Out Data (UART Problem)

Good evening,

 

  

A)

 After many attempts, finally I think I got it .

 

=>

The LCD displays

 

1st  line  LCD = AT

2nd line  LCD = AT || || |||OK|| |||

 

=>

The LED

 

1st time = Shift to another LED

2nd time= ALL the LED lighs up

 

 

1) Is it working correctly ? I mean is this the output you are expecting for AT?

 

2) If correct, then I will change the PB (for AT+CMGF=1 and AT+CMGS = "+60179310740" ) and notify you the output before Tuesday night

 

3) If wrong, then please tell me what should I do next.

 

 

B)

 

   In the meantime, how to write a code to read the SMS input and trigger the specific LED, like shown below.

 

SMS Input        GPIO LED

   

     1            =>          0

 

     2            =>          1

 

     3            =>          2

 

     4            =>          3

 

 

 For example (in the attachment there is a diagram taken from the Hyperterminal):-

Note :- Blue is from PC

             Red  is from Modem

             Green is comment

 

 

AT

OK

AT+CMGF=1

OK

AT+CMGR=6 //Always read at index 6

+CMGR: "REC READ", "+60166223610",,"09/03/10,18:02:35+32"

1 // The input is one, It need to extract this input so that it can trigger the First LED only

 

OK

 

 

 

 Please reply to me as soon as possible.

 

Thank you very much . I really appreciate your help.

Receive.JPG
0 Kudos
Explorer
Explorer
10,620 Views
Registered: ‎12-06-2007

Re: Very Difficult , Need Aid:- FPGA Not Sending Out Data (UART Problem)

Good evening

 

 For your information the previous mail I used

 

Board   :-Virtex4 ML401 (NOT Spartan)

Cable    :-straight cable

Modem :-SIM508

 

Thank you

0 Kudos
Explorer
Explorer
10,932 Views
Registered: ‎04-06-2009

Re: Very Difficult , Need Aid:- FPGA Not Sending Out Data (UART Problem)U f

Congrats! So you finally made your FPGA to communicate with the Modem.

All LED ON means you want to press the PB to repeat. 

Now try to understand the code which I have sent you and try to modify according to your requirement.

 

Already in the code I am saving the received data in an array - So you can check it - You can check in  particular position what data ou are getting.

 

Shantanu 

 

Shantanu Sarkar
http://www.linkedin.com/pub/shantanu-sarkar/0/33a/335
0 Kudos
Explorer
Explorer
10,892 Views
Registered: ‎12-06-2007

Re: Very Difficult , Need Aid:- FPGA Not Sending Out Data (UART Problem)

Good evening, 

 

    Thank you for replying. So sorry disturbing you . I know you are busy. But i really need your help. I spent this few days understanding your coding. but there are some questions that i want to ask you ;-

 

1)

    RED  = Do not understand the function

    BLUE = The question regarding the RED

 

a) Please explain in detail of the RED purpose .

 

b) I having problem understanding the calculation LCD-hexadecimal relationship. Can you explain to me in detail. OR do you have any articles or references for that? I would like to read. I read in the internet , but I got confuse.

 

//========================================================================= 

// Located in: microblaze_0/include/xparameters.h
#include "xparameters.h"

#include "uartlite_header.h"
#include "xbasic_types.h"
#include "xgpio.h"
#include "gpio_header.h"

/************************** Constant Definitions ****************************/
//The following constant is used to for Delay Counter
#define DELAY_CONSTANT     10000


/*
 * The following constant controls the length of the buffers to be sent
 * and received with the UART, this constant must be 16 bytes or less since
 * this is a single threaded non-interrupt driven example such that the
 * entire buffer will fit into the transmit and receive FIFOs of the UART
 */
#define TEST_BUFFER_SIZE      16
#define GLOBAL_BUFFER_SIZE 32 //Max limit of Global_RX_Buffer
#define No_OF_COMMANDS       4   //hERE i'VE DEFINED 4 COMMANDS


/************************** Function Prototypes ****************************/
void Func_Delay(int Loop_counter);
void Send_Byte_to_LCD(Xuint32 LCDBit);
void Send_PKT_to_LCD(char *LCD_Byte,Xuint8 LineNo);
//Function To Clear the display to LCD
void Clear_LCD(void);
//Display Failure Message in LCD
void Disp_Failure_Msg(void);

//Reset Global RX Buffer and its End Pointer
void Reset_Global_Buffer(void);

//Send Commands to Modem thru DCE Rs232 Port
XStatus  Send_Command_To_Modem(unsigned char * Command_Text);
//Get Response of the Command set
void Get_Response_of_Command(Void);
//Function To SEND cARRIAGE rETURN & LINE fEED TO RS232 PORT
XStatus Send_End_of_Text_to_RS232(Xuint16 DeviceId);

//Function To wait for Push Button to be pressed
Xuint32 Wait_for_PB(void);

 

//====================================================
//Global Variables
extern Xuint8 Global_RX_Buffer[GLOBAL_BUFFER_SIZE]; /* Global Buffer for Receiving Data */
extern unsigned int Global_RX_Buf_EndPTR; /* Global Pointer pointind end of the Global Buffer for Receiving Data */

 

//-------------------------------------------------------------------

int main (void)
{

   Xuint32 LCDBit; 
   Xuint32 LedBit;
   Xuint32 Temp32Bit;
   Xuint32 Dip_SW_Val; 
 

   //Set the Flag when the serial communication gets syncronized between FPGA & Modem
   Xuint32 Flag_Syncronize = 0;  Why do we to create Flag? What is the function?
 

   XStatus status;
   int Index;
 //------------------------------------------------------------------------
 //*************************************************************************
   //Enable and initialize cache
   #if XPAR_MICROBLAZE_0_USE_ICACHE
      microblaze_init_icache_range(0, XPAR_MICROBLAZE_0_CACHE_BYTE_SIZE);
      microblaze_enable_icache();
   #endif

   #if XPAR_MICROBLAZE_0_USE_DCACHE
      microblaze_init_dcache_range(0, XPAR_MICROBLAZE_0_DCACHE_BYTE_SIZE);
      microblaze_enable_dcache();
   #endif
 //*************************************************************************

 //-------------------------------------------------------------------
 //Initialise LCD
 {
   //XStatus status;

   Func_Delay(1);//Initial PWR On Delay > 15mSec
   //------------------------------------------------------------------- 
   // Set for 4-bit LCD mode
   //-------------------------------------------------------------------   
   LCDBit=0x03; why is it 0x03? What does it do?
   Send_Byte_to_LCD(LCDBit);
   Func_Delay(1); //>4.1mSec
   //-------------------------------------------------------------------   
   LCDBit=0x03; Why it appear another time? What the purpose doing it again ?
   Send_Byte_to_LCD(LCDBit);
   Func_Delay(1);//>100uSec
   //-------------------------------------------------------------------   
   LCDBit=0x03; What the purpose doing it again ?
   Send_Byte_to_LCD(LCDBit);
   Func_Delay(1);//>100uSec
   //-------------------------------------------------------------------   
   LCDBit=0x02; //4 Bit /  why is it 0x02? What does it do?
   Send_Byte_to_LCD(LCDBit);
   Func_Delay(1);//>100uSec
   //-------------------------------------------------------------------   
   //2 Lines / 5X7
   LCDBit=0x02; //4 Bit /  Why it appear another time? What the purpose doing it again ?
   Send_Byte_to_LCD(LCDBit);
   Func_Delay(1);//>100uSec
   LCDBit=0x08;
   Send_Byte_to_LCD(LCDBit);
   Func_Delay(1);//>100uSec
   //-------------------------------------------------------------------   
   //Function To Clear the display to LCD
   Clear_LCD();
   //-------------------------------------------------------------------   
   //Initialization ends here
   //-------------------------------------------------------------------   
   Send_PKT_to_LCD("Testing LCD",1);
   Send_PKT_to_LCD("Press any PB",2);

 }
 //-------------------------------------------------------------------------
 status = Out_GPIO(XPAR_LEDS_DEVICE_ID, 0xFF); Just want to ensure that this will light up all the LEDs . But we need to put it in status?
 Temp32Bit =Wait_for_PB();
 status = Out_GPIO(XPAR_LEDS_DEVICE_ID, 0x00); Just want to ensure that this will not light up any the LEDs . But we need to put it in status?
 //-------------------------------------------------------------------------
 do//Clear the RX Buffer as a initialization
 {  Func_Delay(5);
    Temp32Bit = UartLite_Receive_Data(XPAR_RS232_DCE_DEVICE_ID);
 }while(Temp32Bit > 0);
 //-------------------------------------------------------------------------
 
 //For syncronization Send "AT\r" to Modem and check for "AT" in the Received byte
 //Repeat untill "AT" is not received.
 Clear_LCD();
 Flag_Syncronize = 0; //Reset the Flag
 Send_PKT_to_LCD("Synchronizing...",1);
 //-------------------------------------------------------------------------
 do
 {
  Func_Delay(200);
  if((++LedBit)>= 0xFF)LedBit=0x00; why do we need to do this? What is the purpose?
  status = Out_GPIO(XPAR_LEDS_DEVICE_ID, LedBit);
  
  Reset_Global_Buffer();
  Send_PKT_to_LCD("                ",2); Why is it blank? What is the purpose making it empty?
  
  status = Send_Command_To_Modem("AT");
  if (status != XST_SUCCESS)
  Disp_Failure_Msg(); //Display Failure Message in LCD
  status = Send_End_of_Text_to_RS232(XPAR_RS232_DCE_DEVICE_ID); 
  if (status != XST_SUCCESS)
  Disp_Failure_Msg(); //Display Failure Message in LCD
  
  Get_Response_of_Command();
  for(Index=0; Index < Global_RX_Buf_EndPTR; Index++) What actually this for loop does? Why the Flag_Syncronize should be 1?
  {

     if((Global_RX_Buffer[Index] == 'A') && (Global_RX_Buffer[Index+1] == 'T'))

         Flag_Syncronize = 1;

  }
  if(Flag_Syncronize > 0)break;
 }while(1);
 //-------------------------------------------------------------------------
 //Now ready to communicate.....
 Clear_LCD();
 Send_PKT_to_LCD(&Global_RX_Buffer[0],2); what does it display? Why it is 0 index in "&Global_RX_Buffer[0]" ?
 Send_PKT_to_LCD("Ready",1);
 for(Index=0,LedBit=0x01; Index < 8; Index++)
 {
  Send_PKT_to_LCD(".",0);
  Func_Delay(200);
  status = Out_GPIO(XPAR_LEDS_DEVICE_ID, LedBit);
  LedBit=LedBit << 1;
 }

 status = Out_GPIO(XPAR_LEDS_DEVICE_ID,0x00); 
 Clear_LCD();
 //-------------------------------------------------------------------------
 
 while(1)
 {
  
  //-------------------------------------------------------------------------
  
  if((++LedBit)>= 0xFF) What does it means? Why it has ++LedBit? what is the function of ++LedBit?

     ledBit=0x00;


  status = Out_GPIO(XPAR_LEDS_DEVICE_ID, LedBit);
  
  Reset_Global_Buffer();
  //-------------------------------------------------------------------------
  status = Input_Gpio(XPAR_DIP_SW_DEVICE_ID, &Dip_SW_Val); what is the function of doing this ?
  if (status != XST_SUCCESS)
  {
   Disp_Failure_Msg(); //Display Failure Message in LCD
   break;
  }
  //-------------------------------------------------------------------------
  switch(Dip_SW_Val)
  {
   case 0x01:
   Send_PKT_to_LCD("AT+CMGF=1",1);
   status = Send_Command_To_Modem("AT+CMGF=1");
   break;

   case 0x02:
   Send_PKT_to_LCD("AT+CMGS=+60179310740",1);
   //Breaking the Command as one cannot send more than 16 bytes at a time.
   status = Send_Command_To_Modem("AT+CMGS=");
   if (status != XST_SUCCESS)break;
   status = Send_Command_To_Modem("+60179310740");   
   break;
   
   default:
   Send_PKT_to_LCD("AT",1);
   status = Send_Command_To_Modem("AT");
  }
  //------------------------------------------------------------------------- 
  if (status != XST_SUCCESS)
  {
   Disp_Failure_Msg(); //Display Failure Message in LCD
   break;
  }
  //-------------------------------------------------------------------------
  status = Send_End_of_Text_to_RS232(XPAR_RS232_DCE_DEVICE_ID); 
  if (status != XST_SUCCESS)
  {
   Disp_Failure_Msg(); //Display Failure Message in LCD
   break;
  }
  //-------------------------------------------------------------------------
  Get_Response_of_Command();
  status = Out_GPIO(XPAR_LEDS_DEVICE_ID, 0xFF);
  Temp32Bit =Wait_for_PB(); What is the reason of putting it in 'Temp32Bit" ?
  
  Clear_LCD();

 }


 
 //*************************************************************************
   /*
    * Disable cache and reinitialize it so that other
    * applications can be run with no problems
    */
   #if XPAR_MICROBLAZE_0_USE_DCACHE
      microblaze_disable_dcache();
      microblaze_init_dcache_range(0, XPAR_MICROBLAZE_0_DCACHE_BYTE_SIZE);
   #endif

   #if XPAR_MICROBLAZE_0_USE_ICACHE
      microblaze_disable_icache();
      microblaze_init_icache_range(0, XPAR_MICROBLAZE_0_CACHE_BYTE_SIZE);
   #endif
 //*************************************************************************
   return 0;
}
//---------------------------------------------------------------------------
//Function required for Time Delay
void Func_Delay(int Loop_counter)
{
 volatile  int i;
 volatile  int j;
 
 for(i=0; i<= Loop_counter; i++)
 {
  for(j=0; j<=DELAY_CONSTANT; j++);
 }

}
//---------------------------------------------------------------------------

//Function To send Byte to LCD
void Send_Byte_to_LCD(Xuint32 LCDBit)
{
 XStatus status;
 
 status = Initialise_LCD(XPAR_LCD_4BIT_DEVICE_ID);//Initialize the GPIO used for LCD
 status = Out_LCD(XPAR_LCD_4BIT_DEVICE_ID, LCDBit);  what is the purpose of the "status"?
 Func_Delay(0);
 //Toggle Enable Bit
 status = Out_LCD(XPAR_LCD_4BIT_DEVICE_ID, (LCDBit | 0x40) ); Why is it OR? And why is it 0x40? how do you calculate?
 Func_Delay(0);
 status = Out_LCD(XPAR_LCD_4BIT_DEVICE_ID, (LCDBit & 0x3F) ); Why is it AND? And why is it 0x3F? how do you calculate?

 Func_Delay(0); 
}
//------------------------------------------------------------------
//Function To send Packet to LCD
void Send_PKT_to_LCD(char *LCD_Byte, Xuint8 LineNo)
{
 static Xuint8 No_of_Char;
 Xuint32 LCDBit;
 Xuint8 LCD_Byte_Ptr;
 
 if ((LineNo & 0x03) > 0)//New Line 0x03 denote what ?
 {
   if (LineNo == 2) 2 denote what?
   {LCDBit=0x0C;} //Set Addr to 2nd Line 0x0C denote what?
   else
   {LCDBit=0x08; }//If Bit 1 is High (1 or 3) - Set Addr to 1st Line 0x08 denote what?
 
  Send_Byte_to_LCD(LCDBit);
  No_of_Char = 0; why  it should be 0?
  Send_Byte_to_LCD(0x00); what is 0x00 means?
 }
 No_of_Char = 0; why need to do it again? what is the purpose?
 //If 0 then continuation to the previous
 //ie same line as previous


 for(LCD_Byte_Ptr=0; ;LCD_Byte_Ptr++) what actually this for loop does ?
 {
    if(LCD_Byte[LCD_Byte_Ptr]<=0)

      break;
   

   LCDBit = 0x20 | ((LCD_Byte[LCD_Byte_Ptr]>>4) & 0x0F); what purpose of this ? Whay is it 0x20?
  Send_Byte_to_LCD(LCDBit);

   LCDBit =0x20 | (LCD_Byte[LCD_Byte_Ptr] & 0x0F);
  Send_Byte_to_LCD(LCDBit);
  
  if(++No_of_Char > 16)
  {
    LCDBit=0x08; //Set Addr to 1st Line
    Send_Byte_to_LCD(LCDBit);
    Send_Byte_to_LCD(0x00); why it should be 0x00?
    No_of_Char = 0;
    break;
  }  
 }

}
//-------------------------------------------------------------------------
//Function To Clear the display to LCD
void Clear_LCD(void)
{

 Xuint32 LCDBit;
 //-------------------------------------------------------------------   
 
 LCDBit=0x00;//
 Send_Byte_to_LCD(LCDBit);
 Func_Delay(0);
 LCDBit=0x08; //Display Off why is it 0x08? What the function of this ?
 Send_Byte_to_LCD(LCDBit);
 Func_Delay(0);
 //-------------------------------------------------------------------   
 LCDBit=0x00;//4 Bit  why is it 0x00? What the function of this ? 
 Send_Byte_to_LCD(LCDBit);
 Func_Delay(0);
 LCDBit=0x01; //Clear Display why is it 0x01? 
 Send_Byte_to_LCD(LCDBit);
 Func_Delay(0);
 //-------------------------------------------------------------------   
 LCDBit=0x00;//4 Bit  why is it 0x00? What the function of this ? 
 Send_Byte_to_LCD(LCDBit);
 Func_Delay(0);
 LCDBit=0x06; //Entry Mode - Incremental / No Shift why is it 0x06? What the function of this ? What increment ?
 Send_Byte_to_LCD(LCDBit);
 Func_Delay(0);
 //-------------------------------------------------------------------   
 LCDBit=0x00;//4 Bit  why is it 0x00? What the function of this ? 
 Send_Byte_to_LCD(LCDBit);
 Func_Delay(0);
 LCDBit=0x0E; //Display On - Cursor On / No Blinking why is it 0x0E? What the actually it does ? 
 Send_Byte_to_LCD(LCDBit);
 Func_Delay(0);
 //-------------------------------------------------------------------   

}
//----------------------------------------------------------------------        
//Send Commands to Modem thru DCE Rs232 Port
XStatus  Send_Command_To_Modem(unsigned char * Command_Text)
{
 XStatus status;
 unsigned int ReceivedCount;
 
 //Clear RX Buffer before sending Data
 ReceivedCount = UartLite_Receive_Data(XPAR_RS232_DCE_DEVICE_ID); 
 Func_Delay(10); 
 
 status = UartLite_Send_Data(XPAR_RS232_DCE_DEVICE_ID, & Command_Text[0]);
   if (status != XST_SUCCESS) return XST_FAILURE;
 else return status; 

}
//-------------------------------------------------------------------------
//Get Response of the Command set
void Get_Response_of_Command(Void)
{
 unsigned int ReceivedCount;

 do//Wait till there is no data
 {  Func_Delay(5);
  ReceivedCount = UartLite_Receive_Data(XPAR_RS232_DCE_DEVICE_ID);
 }while(ReceivedCount <= 0); What the actually it does ? 
 
 do//Keep on receiving till buffer is not empty
 {  Func_Delay(5);
  ReceivedCount = UartLite_Receive_Data(XPAR_RS232_DCE_DEVICE_ID);
 }while(ReceivedCount > 0); What the actually it does ? 

 Send_PKT_to_LCD(&Global_RX_Buffer[0],2); What the actually it does ? Why is the GLOBAL_RX_Buffer index is 0?

}

 

 

//Function To SEND cARRIAGE rETURN & LINE fEED TO RS232 PORT
XStatus Send_End_of_Text_to_RS232(Xuint16 DeviceId)
{
 XStatus status;

 char  End_of_Text[3];
 
 End_of_Text[0]= 0x0D; why is it 0x0D?
 End_of_Text[1]= 0x0A; why is it 0x0A ?
 End_of_Text[2]= 0x00
why is it 0x00 ?
 status = UartLite_Send_Data(DeviceId, &End_of_Text[0]);
   return status;

}
//-------------------------------------------------------------------------
//Function To wait for Push Button to be pressed
Xuint32 Wait_for_PB(void)
{
 XStatus status;
 Xuint32 PB_Value = 0;
 do
 {
  status = Input_Gpio(XPAR_PB_SWS_DEVICE_ID, &PB_Value);
 }while((PB_Value <= 0)||(status == XST_FAILURE));
 return PB_Value;
}
//-------------------------------------------------------------------------
//Display Failure Message in LCD
void Disp_Failure_Msg(void)
{
 Xuint32 PB_SW_Val;
 XStatus status;
 
 Clear_LCD();
 Send_PKT_to_LCD("FAILURE",1);
 Send_PKT_to_LCD("Press PB Switch",2);
 
 status = Out_GPIO(XPAR_LEDS_DEVICE_ID, 0xFF);
 PB_SW_Val = Wait_for_PB();
}
//-------------------------------------------------------------------------
//Reset Global RX Buffer and its End Pointer
void Reset_Global_Buffer(void)
{
 unsigned int Index;
 
 for(Index=0;Index<GLOBAL_BUFFER_SIZE;Index++)
 Global_RX_Buffer[Index]= 0x00; why is it 0x00? What does it do ?
 
 Global_RX_Buf_EndPTR = 0; Why 0? Is it the end pointer?
}

//=========================================================================  

 

2)

 

a)

      Based on the below diagram, where is function part (above coding, please highlight for me in GREEN) for receiving the data from the Modem? I still do not understand how you did it ? How can the coding differentiate OK or ERROR

 

  

I am sorry if my questions is silly. But I really want to understand your wonderful coding throughly, so that i will be confident during my presentation. 

 

Please reply to me as soon as possible. 

 

Thank you very much . I really do appreciate your kind help.

Receive.JPG
0 Kudos
Explorer
Explorer
10,877 Views
Registered: ‎12-06-2007

Re: Very Difficult , Need Aid:- FPGA Not Sending Out Data (UART Problem)

Good morning ,

 

   Are you there? I really need your help.

 

Thank you

Tags (1)
0 Kudos
Explorer
Explorer
10,868 Views
Registered: ‎04-06-2009

Re: Very Difficult , Need Aid:- FPGA Not Sending Out Data (UART Problem)

Regarding LCD pl find the attachment. Pl go thru it.

Shantanu

Shantanu Sarkar
http://www.linkedin.com/pub/shantanu-sarkar/0/33a/335
0 Kudos
Explorer
Explorer
10,699 Views
Registered: ‎12-06-2007

Re: Very Difficult , Need Aid:- FPGA Not Sending Out Data (UART Problem)

Good evening

 

  I am sorry to disturb you. But I need your help. I am trying for the past few weeks but I can rectify this problem

 

AT  //I type at the hyperterminal

OK // respond by the modem

AT+CMGF=1

OK

AT+CMGR=6 // read SMS at the index 6

+CMGR: "REC READ","+60166223610",,"09/03/10,18:02:35+32"
1  // This is the only input that need to extracted.

OK

 

I altered the code but the answered I getting are not static . It always changing

 

1) Sometimes it appears like this at the LCD

 

1|| ||| OK

 

2) When I rerun again, it often it appears like this at the LCD

 

2" || ||| 1 || ||| OK

 

or 

 

32" || ||| 1 || ||| OK

 

or etc 

 

 

The code is in the attachment. How can I rectify this problem to get a static answer.

0 Kudos
Explorer
Explorer
10,699 Views
Registered: ‎12-06-2007

Re: Very Difficult , Need Aid:- FPGA Not Sending Out Data (UART Problem)U f

Good evening,

 

   Above mail ,I just added this code in the program.

 

  void Get_MResponse_of_Command(Void) // I change the name
  {
       unsigned int ReceivedCount;
       char s ; //I added this
 
 

        do//Wait till there is no data
       {  Func_Delay(5);
           ReceivedCount = UartLite_Receive_Data(XPAR_RS232_DCE_DEVICE_ID);
       }while(ReceivedCount <= 0);
 
      do//Keep on receiving till buffer is not empty
      {  Func_Delay(5);
         ReceivedCount = UartLite_Receive_Data(XPAR_RS232_DCE_DEVICE_ID);     
      }while(ReceivedCount > 0);
 
 
       //ADDED HERE  
    

      Send_PKT_to_LCD(&Global_RX_Buffer[25],2); // it will appear  1 || ||| OK
      Global_RX_Buffer[26]= 0x00;
// Delete the remaining after the 1 . Eg:- This  1 || ||| OK  will appear  1


      //UartLite_Send_Data(XPAR_RS232_DCE_DEVICE_ID, &Global_RX_Buffer[25]);    // Send 1 to hyperterminal so that I can see
 
       char *z = &Global_RX_Buffer[25]; // Change it to char type
 
  
       if(*z == '1')
      {
           Out_GPIO(XPAR_LEDS_DEVICE_ID, 0xFF);  //light up LED
       }

}

 

 

 The only problem I facing is that the input extracted is not always the same . How can I get an accurate input so that I can trigger the LED.

 

 

Thank you

0 Kudos
Explorer
Explorer
10,697 Views
Registered: ‎12-06-2007

Re: Very Difficult , Need Aid:- FPGA Not Sending Out Data (UART Problem)

Good evening,

 

     I am sorry for not replying to you earlier beacuse I was trying to solve the problem by myself until I did not notice the time flew so fast.

Please do not get annoyed. I  had altered the coding , I got the output , but it was not accurate. My supervisor want an accurate answer.

Please help me.  

 

 

 

Your help is really being appreciated. Thank you

0 Kudos
Explorer
Explorer
10,652 Views
Registered: ‎12-06-2007

Re: Very Difficult , Need Aid:- FPGA Not Sending Out Data (UART Problem)

Good morning,

 

  Are you there ? Please help me .

 

Thank you

Tags (1)
0 Kudos
Explorer
Explorer
10,605 Views
Registered: ‎04-06-2009

Re: Very Difficult , Need Aid:- FPGA Not Sending Out Data (UART Problem)

It seems your buffer "Global_RX_Buffer"  is not getting clear properly.

Any way You want to retrieve the value 1. One option is

1> take 2nd Array

2> Copy the contents of Global_RX_Buffer to it - Copy only the characters "a to z", "A to Z" or "0 to 9". Befory doing the copy make sure all the contents are 0.

3> Start reading from the end. - First valid caharacter you will get is K follwed by O. The next charracter must be 1.

 

For example

32" || ||| 1 || ||| OK 

 

when you are going to store it in the 2nd Array - It will be like this 321OK

Now Reading from End - KO123. (Ignore the content with values 0x00).

 

Hope this will help you.

 

 

Shantanu Sarkar
http://www.linkedin.com/pub/shantanu-sarkar/0/33a/335
0 Kudos
Highlighted
Explorer
Explorer
10,499 Views
Registered: ‎12-06-2007

Re: Very Difficult , Need Aid:- FPGA Not Sending Out Data (UART Problem)

Good morning

 

 

   Sorry to disturb you , but I need your expertise

 

 

 

1) Folder_1

 

=> open the Pic.jpeg

=> If you observe , you can see that the value I extracted is not always same . It should only be 1 , not other value, eg:- 3.

=> How should I rectify this problem

 

 

2) Folder_2

 

=> open the block_diagram.jpeg

=> I want to connect the serial cable (null modem) at the Expansion Header. The pin name (ug080.pdf at page 21 )

=> This are the steps I need to do (if wrong pls let me know )

     1) Change the ucf file

          Net fpga_0_RS232_Uart_RX_pin LOC=AA24;

       

         Ignore this (If I need to change this , what should I change ?)

           Net fpga_0_RS232_Uart_RX_pin IOSTANDARD = LVCMOS33;

 

    

      2) Do the MAX2323 board

 

      3) Connect wire to between MAX2323 and ML401

         

          Rx   = J6,Pin2

          Tx   = J6,Pin4

          Vcc = Pin 3.3V

          Gnd =Gnd

 

      4) Connect wire to between MAX2323 and Serial Port.

 

 

      I reaaly need your help. Please reply to me as soon as possible

 

Thank you

0 Kudos