Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recieving Garbage without anything Sending #10

Open
GrimmsterZed opened this issue Jul 4, 2023 · 7 comments
Open

Recieving Garbage without anything Sending #10

GrimmsterZed opened this issue Jul 4, 2023 · 7 comments
Assignees

Comments

@GrimmsterZed
Copy link

Upon flashing LoRaReceiver.cpp onto my Pico, the device immediately begins recieving garbage, regardless if there's another device sending or not. A sending device does not create a different output. Perhaps this suggests the nature of the issue?

CRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRX' with RSSI 
�pG0����FReceived packet 
'CRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRXCRX' with RSSI 
�pG0����FReceived packet

And so on forever.

@akshayabali
Copy link
Owner

Can you try the DumpRegister Example?

It reads all the registers in the module and prints them. That can help you make sure that you can communicate with the module correctly.

You should be able to read the Version register at 0x42. If you don't see the correct output, the link is not correctly setup and we can debug from there.

@GrimmsterZed
Copy link
Author

GrimmsterZed commented Jul 6, 2023

Well, interestingly, every single register is coming back as 0xC8. Of course, I had to disable the version check to get the dump to run correctly

---- Opened the serial port /dev/ttyACM0 ----
LoRa Dump Registers
0x0: 0xc8
0x1: 0xc8
0x2: 0xc8
0x3: 0xc8
0x4: 0xc8
0x5: 0xc8
0x6: 0xc8
0x7: 0xc8
0x8: 0xc8
0x9: 0xc8
0xa: 0xc8
0xb: 0xc8
0xc: 0xc8
0xd: 0xc8
0xe: 0xc8
0xf: 0xc8
0x10: 0xc8
0x11: 0xc8
0x12: 0xc8
0x13: 0xc8
0x14: 0xc8
0x15: 0xc8
0x16: 0xc8
0x17: 0xc8
0x18: 0xc8
0x19: 0xc8
0x1a: 0xc8
0x1b: 0xc8
0x1c: 0xc8
0x1d: 0xc8
0x1e: 0xc8
0x1f: 0xc8
0x20: 0xc8
0x21: 0xc8
0x22: 0xc8
0x23: 0xc8
0x24: 0xc8
0x25: 0xc8
0x26: 0xc8
0x27: 0xc8
0x28: 0xc8
0x29: 0xc8
0x2a: 0xc8
0x2b: 0xc8
0x2c: 0xc8
0x2d: 0xc8
0x2e: 0xc8
0x2f: 0xc8
0x30: 0xc8
0x31: 0xc8
0x32: 0xc8
0x33: 0xc8
0x34: 0xc8
0x35: 0xc8
0x36: 0xc8
0x37: 0xc8
0x38: 0xc8
0x39: 0xc8
0x3a: 0xc8
0x3b: 0xc8
0x3c: 0xc8
0x3d: 0xc8
0x3e: 0xc8
0x3f: 0xc8
0x40: 0xc8
0x41: 0xc8
0x42: 0xc8
0x43: 0xc8
0x44: 0xc8
0x45: 0xc8
0x46: 0xc8
0x47: 0xc8
0x48: 0xc8
0x49: 0xc8
0x4a: 0xc8
0x4b: 0xc8
0x4c: 0xc8
0x4d: 0xc8
0x4e: 0xc8
0x4f: 0xc8
0x50: 0xc8
0x51: 0xc8
0x52: 0xc8
0x53: 0xc8
0x54: 0xc8
0x55: 0xc8
0x56: 0xc8
0x57: 0xc8
0x58: 0xc8
0x59: 0xc8
0x5a: 0xc8
0x5b: 0xc8
0x5c: 0xc8
0x5d: 0xc8
0x5e: 0xc8
0x5f: 0xc8
0x60: 0xc8
0x61: 0xc8
0x62: 0xc8
0x63: 0xc8
0x64: 0xc8
0x65: 0xc8
0x66: 0xc8
0x67: 0xc8
0x68: 0xc8
0x69: 0xc8
0x6a: 0xc8
0x6b: 0xc8
0x6c: 0xc8
0x6d: 0xc8
0x6e: 0xc8
0x6f: 0xc8
0x70: 0xc8
0x71: 0xc8
0x72: 0xc8
0x73: 0xc8
0x74: 0xc8
0x75: 0xc8
0x76: 0xc8
0x77: 0xc8
0x78: 0xc8
0x79: 0xc8
0x7a: 0xc8
0x7b: 0xc8
0x7c: 0xc8
0x7d: 0xc8
0x7e: 0xc8
0x7f: 0xc8

Sorry accidentally closed issue

@akshayabali
Copy link
Owner

Can you use this code to test the SPI communication? This is a simple code that sets up SPI and reads the Version Register and prints it. There might be errors as I couldn't, but they should be minor. If you don't see the correct output I'll suggest to debug the SPI communication between the module and the pi pico.

#include <string.h>
#include "pico/stdlib.h"
#include "pico/binary_info.h"
#include "hardware/gpio.h"
#include "hardware/spi.h"
#include <stdio.h> 

#define SPI_PORT                 spi0
#define REG_VERSION              0x42
#define PIN_MISO 16
#define PIN_CS   8
#define PIN_SCK  18
#define PIN_MOSI 19
#define LORA_DEFAULT_SS_PIN        8
#define LORA_DEFAULT_RESET_PIN     9
#define LORA_DEFAULT_DIO0_PIN      7


int main() {

    
    // setup pins
    int _ss = LORA_DEFAULT_SS_PIN;
    int _reset = LORA_DEFAULT_RESET_PIN;
    int _dio0 = LORA_DEFAULT_DIO0_PIN;

    // setup pins
    gpio_init(_ss);
    gpio_set_dir(_ss, GPIO_OUT);
    // set SS high
    gpio_put(_ss, 1);

    if (_reset != -1) {
        gpio_init(_reset);
        gpio_set_dir(_reset, GPIO_OUT);

        // perform reset
        gpio_put(_reset, 0);
        sleep_ms(10);
        gpio_put(_reset, 1);
        sleep_ms(10);
    }

    // start SPI
    spi_init(SPI_PORT, 12500);
    gpio_set_function(PIN_MISO, GPIO_FUNC_SPI);
    gpio_set_function(PIN_SCK, GPIO_FUNC_SPI);
    gpio_set_function(PIN_MOSI, GPIO_FUNC_SPI);


    // Make the SPI pins available to picotool
    bi_decl(bi_3pins_with_func(PIN_MISO, PIN_MOSI, PIN_SCK, GPIO_FUNC_SPI));

    gpio_init(PIN_CS);
    gpio_set_dir(PIN_CS, GPIO_OUT);
    gpio_put(PIN_CS, 1);

    // Make the CS pin available to picotool
    bi_decl(bi_1pin_with_name(PIN_CS, "SPI CS"));

    // check version
    uint8_t address = REG_VERSION;
    uint8_t value = 0x00;
    uint8_t version;

    gpio_put(_ss, 0);

    spi_write_blocking(SPI_PORT, &address , 1);
    spi_write_read_blocking(SPI_PORT, &value, &version, 1);

    gpio_put(_ss, 1);

    printf("Version: 0x%x\n", version);
}
`

@GrimmsterZed
Copy link
Author

GrimmsterZed commented Jul 11, 2023

Sorrry for the delayed response!

Running your code above the output is 0xA2. Assuming the correct register is 0x42 then there may definitely be something wrong with SPI. I have attached a picture of my connections just in case there's something glaringly incorrect. Otherwise I'm at a bit of a loss as to why it's not returning correct values.

I've also tested the register dump with a new Pico and a new LoRa chip to the same results.

@akshayabali
Copy link
Owner

Can you comment out lines 120 to 123 and try to use the library, as you are using a different chip, it might not be working for you.

// uint8_t version = readRegister(REG_VERSION);
//   if (version != 0x12) {
//     return 0;
//   }

@akshayabali akshayabali self-assigned this Jul 14, 2023
@GrimmsterZed
Copy link
Author

GrimmsterZed commented Jul 15, 2023

I have already commented out the version check as I had to in order to run the dumpregisters code

You said you've used this chip before right? I'm worried that all of the opcodes are different otherwise

@Filipeak
Copy link

Hey,

I know I'm quite late, but I think that the issue is in printing the output. Try replacing char* (pointer) to normal char.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants