Skip to content

Instantly share code, notes, and snippets.

@dabelknap
Last active December 28, 2015 07:49
Show Gist options
  • Save dabelknap/7467516 to your computer and use it in GitHub Desktop.
Save dabelknap/7467516 to your computer and use it in GitHub Desktop.
VMEStream VME Register Corruption Example
#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;
}
@dabelknap
Copy link
Author

To compile, place this file in cms-calo-layer1/VMEStream/src, then run make from cms-calo-layer1/VMEStream. The executable test will appear in VMEStream/bin. Then, run the executable a few times.

What should happen
The values stored in tx_size and rx_size should remain 0.

What actually happens
For a few loops, tx_size and rx_size are zero. Then rx_size and/or tx_size gets set to 0xFFFF after a read operation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment