Logo
NGFC_PWMIn_Demo

Demo program for PWMIn IP Core.

The Usage() function shows how to execute the test program, options available and default values set for different configuration variables. The Variables section specifies variables used in the test program, what they specify, the values it holds and can take. The main() function specifies sequence of api calls executed and tested.

Functions

void PWMInUsage ()
 
int main (int argc, char *argv[])
 
void Display_channels ()
 

Variables

int filter_count =-1
 Filter count for the PWMIn IP Core. It takes values >= 0 and defaults to -1 (none)
 
int fifo_depth =-1
 Fifo depth for the PWMIn IP Core. It takes values >= 0 and <= 127 and defaults to -1 (none)
 
int dead_limit =-1
 Dead limit for the PWMIn IP Core. It takes values >= 0 and defaults to -1 (none)
 
int active_high =-1
 Active high for the PWMIn IP Core. It takes values 0 or 1 and defaults to -1 (none)
 
int channel =-1
 Channel number for the PWMIn IP Core. It takes values 0 to (number of IP Core channels-1) and defaults to -1 (test program executed for all channels)
 
fpgawb_ipcore_pwmin_get_channel_info_t info
 fpgawb_ipcore_pwmin_get_channel_info_t struct to read channel data for the PWMIn IP Core. Check fpgawb_lib.h or api call documentation for more information on the struct members
 
fpgawb_ipcore_pwmin_get_channel_info_t all_info [FPGAWB_MAX_IPCORE_CHANNELS]
 Array of fpgawb_ipcore_pwmin_get_channel_info_t struct to read channel data for the PWMIn IP Core. Check fpgawb_lib.h or api call documentation for more information on the struct members.
 
fpgawb_ipcore_t ip_core
 fpgawb_ipcore_t struct which stores useful information about the IP Core after executing the get IP Info api call. Check fpgawb_lib.h or api call documentation for more information
 
fpgawb_ipcore_pwmin_configure_t config
 fpgawb_ipcore_pwmin_configure_t struct passed as argument to configure channel api call. Check fpgawb_lib.h or api call documentation for more information
 
uint pulse_count
 Pulse count of PWMIn IP Core. It defaults to 0.
 
int xfer_mode = DEF_XFER_MODE
 Transfer mode for the PWMIn IP Core which specifies regular read or MsgDma read. It takes values CCRTNGFC_LIBRARY_PIO_MODE (regular) or CCURPMFC_LIBRARY_MSGDMA_MODE (MsgDma) and defaults to CCURPMFC_LIBRARY_MSGDMA_MODE.
 

Function Documentation

void Display_channels ( )

Step 13: MSGDMA FIRE
fpgawb_IpCore_MsgDma_Fire(handle)
This call commences the MsgDma transfer

Step 14: READ MSGDMA DATA
fpgawb_PWMIn_Get_MsgDma_Info(handle, all_info)
Returns data for all channels in the all_info struct passed as second argument

Step 15: GET PWMIN CHANNEL INFO
fpgawb_PWMIn_Get_Ch_Info(handle, Chan, &Info)
This call is used to get PWMIn channel information which is populated in the Info struct

int main ( int  argc,
char *  argv[] 
)

Step 1: OPEN DEVICE
ccrtNGFC_Open(&handle,board_no,oflags)
Before using any API calls, the user needs to open the device and get a handle. This handle is then used as the first argument in most of the following APIs

Step 2: GET DRIVER INFO
ccrtNGFC_Get_Driver_Info(handle, &binfo)
This call returns useful driver information and saves in the ccrtngfc_driver_info_t structure for later use

Step 3: GET LIBRARY INFO
ccrtNGFC_Get_Library_Info(handle, &linfo)
This call returns useful library information and saves in the ccrtngfc_library_info_t structure for later use

Step 4: GET IP INFO
fpgawb_PWMIn_Get_Ip_Info(handle, &ip_core)
This call returns useful IP Core information and saves in the fpgawb_ipcore_t structure for later use

Step 5: SEIZE MSGDMA
ccrtNGFC_MsgDma_Seize(handle)
Seizes the MsgDma for data transfer

Step 6: MSGDMA INITIALIZE
fpgawb_IpCore_MsgDma_Initialize(handle,&IpCodeSelect)
This call initializes Modular Scatter-Gather DMA for the selected IP Cores specified using the _fpgawb_ipcode_select_t struct. The api call calculates and allocates physical memory for the DMA transfer and configures the DMA Descriptors

Step 7: RESET PWMIN CHANNEL
fpgawb_PWMIn_Reset_Ch(handle, Chan)
This call resets the PWMIn IP Core channel

Step 8: GET PWMIN CHANNEL INFO
fpgawb_PWMIn_Get_Ch_Info(handle, Chan, &info)
This call is used to get PWMIn channel information which is populated in the info struct. This information is used as defaults for the configuration parameters

Step 9: CONFIGURE PWMIN CHANNEL
fpgawb_PWMIn_Configure_Ch(handle, Chan, &config) This call configures the PWMIn channel with the confguration parameters in the config struct

Step 10: GET PWMIN CHANNEL INFO
fpgawb_PWMIn_Get_Ch_Info(handle, Chan, &info)
This call is used to get PWMIn channel information which is populated in the info struct

Step 11: GET PWMIN CHANNEL PULSE COUNT
fpgawb_PWMIn_Get_Ch_Pulsecount(handle, Chan, &pulse_count)
This call is used to get PWMIn channel pulsecount which is returned in the pulse_count parameter

Step 12: RESET PWMIN CHANNEL PULSE COUNT
fpgawb_PWMIn_Reset_Ch_Pulsecount(handle, Chan)
This call is used to reset the PWMIn channel pulsecount

Step 16: RELEASE MSGDMA
ccrtNGFC_MsgDma_Release(handle)
This call releases the seized MsgDma. Release the MsgDma once done with the transfer

Step 17: CLOSE DEVICE
ccrtNGFC_Close(handle)
Closes the device with the handle

void PWMInUsage ( )

Usage:
./fpgawb_ipcore_pwmin [-A active_high] [-b BoardNumber] [-c channelNumber] [-d Delay] [-D dead_limit] [-f filter_count] [-F fifo_depth] [-m xfer_mode]

Options Default value
-A Active High (h/l) existing value from register
-b Board Number or Device Number 0
-c channel Number (0- (NumChans-1)) -1 (all channels)
-d Delay between screen refresh 100 milli-seconds
-D Dead limit - Integer value >=0 existing value from register
-f Filter Count - Integer value >=0 and <=127 existing value from register
-F Fifo Depth - Integer value >=0 and <=127 existing value from register
-m Transfer mode for reading the PWMIn data (p is for Programmed I/O mode and m is for Modular Scatter-Gather DMA mode) MsgDma mode


Examples:
./fpgawb_ipcore_pwmin
./fpgawb_ipcore_pwmin -Ah -b0 -D1000000 -f100 -F127 -mp