linuscomex
Junior Member level 3
Hi bro. I have 2 questions, please answer me.
1-Why sometime for programming of microblaze in xilinx fpga use while(1) loop and sometimes dont?
see below code for example...
2- what is mean #define TCSR0 (*(volatile unsigned long *)(XPAR_TIMER1_BASEADDR+0x00)) in up code and whay somtimes use and somtimes dont?
see below code for example that In which the unused code...
thanks alot.
1-Why sometime for programming of microblaze in xilinx fpga use while(1) loop and sometimes dont?
see below code for example...
Code:
I want to generate a PWM signal using the Timer/Counter IP Core. Nothing shows up.
What I did:
Added the core, connected the PWM0 port of the core to an external pin, added the pin in UCF and declared it as LVCMOS33 (the pin can handle it for sure).
Executed the following code:
#include "stdio.h"
#include "xparameters.h"
#include "xbasic_types.h"
#include "xgpio.h"
//#define TCSR0 XPAR_TIMER1_BASEADDR;
#define TCSR0 (*(volatile unsigned long *)(XPAR_TIMER1_BASEADDR+0x00))
#define TLR0 (*(volatile unsigned long *)(XPAR_TIMER1_BASEADDR+0x04))
#define TCR0 (*(volatile unsigned long *)(XPAR_TIMER1_BASEADDR+0x08))
#define TCSR1 (*(volatile unsigned long *)(XPAR_TIMER1_BASEADDR+0x10))
#define TLR1 (*(volatile unsigned long *)(XPAR_TIMER1_BASEADDR+0x14))
#define TCR1 (*(volatile unsigned long *)(XPAR_TIMER1_BASEADDR+0x18))
int main(){
print("TEST YUE");
TLR0 = 0x26259E; TLR1 = 0x16E35E;
TCSR0=0x604;
TCSR1=0x604;
//also tried 0x204
putnum(TCSR0);
print("TEST YUEfds");
putnum(TCSR1);
return 1;
}
2- what is mean #define TCSR0 (*(volatile unsigned long *)(XPAR_TIMER1_BASEADDR+0x00)) in up code and whay somtimes use and somtimes dont?
see below code for example that In which the unused code...
Code:
#include<xparameters.h>
#include<xstatus.h>
#include<xuartlite.h>
#include<xgpio.h>
#define TEST_BUFFER_SIZE 5 // size of buffer of Uart
Xuint8 SendBuffer[TEST_BUFFER_SIZE];
Xuint8 RecvBuffer[TEST_BUFFER_SIZE];
int main(void){
XUartLite UartLite_DCE;
XGpio led;
XStatus Status;
unsigned int SentCount;
unsigned int ReceivedCount;
int Index;
// Initialize Led_8bit
XGpio_Initialize(&led, XPAR_LEDS_8BIT_DEVICE_ID);
XGpio_SetDataDirection(&led,1,0);
// Initialize Uart_DCE
Status = XUartLite_Initialize(&UartLite_DCE, XPAR_RS232_DCE_DEVICE_ID);
if (Status != XST_SUCCESS){
return XST_FAILURE;
}
// Initialize Buffer
for (Index = 0; Index < TEST_BUFFER_SIZE; Index++){
SendBuffer[Index] = Index;
RecvBuffer[Index] = 0;
}
// Send data
SentCount = XUartLite_Send(&UartLite_DCE, SendBuffer, TEST_BUFFER_SIZE);
if (SentCount != TEST_BUFFER_SIZE){
return XST_FAILURE;
}
// wait for data have been send
while (XUartLite_IsSending(&UartLite_DCE)){
}
// Received data
ReceivedCount = XUartLite_Recv(&UartLite_DCE, RecvBuffer, TEST_BUFFER_SIZE);
if (ReceivedCount != TEST_BUFFER_SIZE){
return XST_FAILURE;
}
// check if data send correctly
for (Index = 0; Index < TEST_BUFFER_SIZE; Index++){
if (SendBuffer[Index] == RecvBuffer[Index])
XGpio_DiscreteWrite(&led, 1, 3); // turn on Led1, Led2
else
XGpio_DiscreteWrite(&led, 1, 192); // turn on Led7, Led8
}
}
thanks alot.