Last active
December 28, 2015 07:49
-
-
Save dabelknap/7467516 to your computer and use it in GitHub Desktop.
VMEStream VME Register Corruption Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <stdint.h> | |
#include <iomanip> | |
#include <log4cplus/logger.h> | |
#include <log4cplus/configurator.h> | |
#include "VMEController.h" | |
#define DATAWIDTH 2 | |
uint32_t ZERO = 0; | |
using std::cout; | |
using std::endl; | |
using std::hex; | |
int test() | |
{ | |
VMEController *vme = VMEController::getVMEController(); | |
cout << vme->write(0x2000, DATAWIDTH, &ZERO) << endl; | |
cout << vme->write(0x2002, DATAWIDTH, &ZERO) << endl; | |
uint32_t* tx_size = (uint32_t*) calloc(1, sizeof(uint32_t)); | |
uint32_t* rx_size = (uint32_t*) calloc(1, sizeof(uint32_t)); | |
for (int i = 0; i < 10; ++i) { | |
printf("-- Loop %d --\n", i + 1); | |
cout << "Reading" << endl; | |
cout << vme->read(0x2000, DATAWIDTH, tx_size) << endl; | |
cout << vme->read(0x2002, DATAWIDTH, rx_size) << endl; | |
printf("tx_size: %d\n", *(tx_size)); | |
printf("rx_size: %d\n", *(rx_size)); | |
cout << "Writing" << endl; | |
cout << vme->write(0x2000, DATAWIDTH, tx_size) << endl; | |
cout << vme->write(0x2002, DATAWIDTH, rx_size) << endl; | |
printf("tx_size: %d\n", *(tx_size)); | |
printf("rx_size: %d\n", *(rx_size)); | |
cout << endl; | |
} | |
return 0; | |
} | |
int main() | |
{ | |
test(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To compile, place this file in
cms-calo-layer1/VMEStream/src
, then runmake
fromcms-calo-layer1/VMEStream
. The executabletest
will appear inVMEStream/bin
. Then, run the executable a few times.What should happen
The values stored in
tx_size
andrx_size
should remain 0.What actually happens
For a few loops,
tx_size
andrx_size
are zero. Thenrx_size
and/ortx_size
gets set to0xFFFF
after a read operation.