Project: Download data from SDRAM to SAMD21

Hi Everyone!

I’ve been working with a Vidor template, together with a Purisame project that uses the SDRAM to send image trough the vidor hdmi port.

I removed the HDMI part, and modified a little the SDRAM driver, and added a UART_TX module.

Code is intended to write the memory address LSB to every location, once memory is filled, it starts reading the data and then send it to Vidor digital pin 10, configured as a UART_RX.

Sadly, when I load everything to the board, I can’t see anything on the serial monitor.

I’d like to know what could be wrong with this idea

As the MKRVIDOR.top template gives the option to add a file named user.v, I’m posting my code files on a zip

SS

And here’s my Arduino Sketch, that loads the app.h generated from the vidorcvt.exe with the Quartus output files:

#include <Arduino.h>
#include <wiring_private.h>
#include “jtag.h”

#define TDI 12
#define TDO 15
#define TCK 13
#define TMS 14
#define MB_INT 28
#define MB_INT_PIN 31
#define SIGNAL_OUT 41 //B5 L16
#define SIGNAL_IN 33 //B2 N2

#define no_data 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
0x00, 0x00, 0x00, 0x00 \

#define NO_BOOTLOADER no_data
#define NO_APP no_data
#define NO_USER_DATA no_data

attribute ((used, section(".fpga_bitstream_signature")))
const unsigned char signatures[4096] = {
//#include “signature.ttf”
NO_BOOTLOADER,

0x00, 0x00, 0x08, 0x00,
0xA9, 0x6F, 0x1F, 0x00, // Don’t care.
0x20, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x65, 0x73, 0x2d, 0x65, 0x6d, 0x62, 0x61, 0x72, 0x71, 0x75, 0x65, 0x73, 0x2e, 0x66, 0x72, 0x20, 0x00, 0x00, 0xff, 0xf0, 0x0f,
0x01, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, // Force

NO_USER_DATA,
};
attribute ((used, section(".fpga_bitstream")))
const unsigned char bitstream = {
#include “app.h”
};
// Declaracion de constantes (editable)
const int PULSE=6;
const int SUBPULSE = 7;

// the setup function runs once when you press reset or power the board

Uart Serial2 (&sercom3, 10, 11, SERCOM_RX_PAD_1, UART_TX_PAD_0);

void setup() {

int ret;
uint32_t ptr[1];

//enableFpgaClock();
pinPeripheral(30, PIO_AC_CLK);
clockout(0, 1);
delay(1000);

//Init Jtag Port
ret = jtagInit();
mbPinSet();

// Load FPGA user configuration
ptr[0] = 0 | 3;
mbEveSend(ptr, 1);

// Give it delay
delay(1000);

// Disable all JTAG Pins (usefull for USB BLASTER connection)
pinMode(TDO, INPUT);
pinMode(TMS, INPUT);
pinMode(TDI, INPUT);
pinMode(TCK, INPUT);

// Configure other share pins as input too
pinMode(SIGNAL_IN, INPUT); // oSAM_INT
pinMode(MB_INT_PIN, INPUT);
pinMode(MB_INT, INPUT);

//Esto es editable
pinMode(PULSE, OUTPUT);
pinMode(SUBPULSE, OUTPUT);

Serial.begin(115200);
Serial2.begin(115200);

// Assign pins 10 & 11 SERCOM functionality

pinPeripheral(10, PIO_SERCOM);
pinPeripheral(11, PIO_SERCOM);

pinMode(0,INPUT);
pinMode(1,INPUT);
}

int flag=0;
int done=0;
int ByteRead;

void loop() {
flag = digitalRead(0);
done = digitalRead(1);
if (Serial2.available())
{
ByteRead = Serial2.read();
if (flag == 0 && done ==1);{
Serial.print(ByteRead, BIN);
}
}
Serial.println();

}

void SERCOM3_Handler()
{
Serial2.IrqHandler();
}

I created the Sercom using a MKR1000 example, because I couldn’t find any info on UART on MKRVIDOR 4000

I would apreciate any feedback, or advice, or help to notice something that I could be missing

My BR

Jesus Abimael López

verilog_code_files.zip (9.23 KB)

verilog_code_files.zip (9.23 KB)

Should you use wMEM_CLK for internal memory related clocking and oSDRAM_CLK for SDRAM chip clocking. These have same frequency but 180 degrees phase shift. At least that's how mailbox example was done.

Edit:
Also comment code in English if you want more people to understand and comment about your code.
I can read and understand what your code does but when not understanding comments I don't know was that how you plan to work.

Do you have an oscilloscope by any chance? Might be worth checking if the uart tx signal is coming out of the FPGA. If not, it might not be configured properly.