Re. pcm3002 configured for 16 bit data transfers - codec

I am trying to do a loopback program (get data in, and send it out
without any processing) on a 5416 DSK. I am using the on board
PCM3002 codec and it is configured for 16-bit data transfer. I also
have McBSP2 configured for 16-bit receive/transfer. The following are
the register values for McBSP2 and PCM3002 codec,
McBSP2 registers:
SPCR1 = 0x2020 (also tried SPCR1 = 0x2000)
SPCR2 = 0x0000
RCR1 = 0x0040
RCR2 = 0x0041
XCR1 = 0x0040
XCR2 = 0x0040 (also tried XCR2 = 0x0041, and 0x0042)
PCR = 0x000C
PCM3002 registers:
Register0 = 0x01FF
Register1 = 0x03FF
Register2 = 0x0482
Register3 = 0x0600
The CPLD codec clock register is configured for a 24 KHz
sampling rate. I don't need to configure SRGR because the CPLD on
board provides the frame sync signal. I am sure that rest of my
configuration is correct, because I am able configure PCM3002
McBSP2 for a 20-bit transfer/receive loopback program and it works
fine. Can somebody please tell me what is wrong here? Any help will
be appreciated.

Related

PIC 32 baud rate

i have a PIC32MX460F512L. I am setting up a UART communication with raspberry Pi 3. And i made also some tests with mi PC Windows serial terminal (Putty, Teraterm etc.). I am having stucking problems, because the raspberry sends and receives only rubbish. Then i tested it with putty on Windows and i noticed strange things. For example the uart baud rate on the board is set as 9600, and to send and receive data on windows i have to set putty's baud rate to 130 !! Then i had a look to my PCLK settings on pic and it seems like everything is correct since there is an external clk oscillator of 8MHz. I post the code below .
PIC CODE:
#define GetSystemClock() (80000000ul) // Hz
#define GetInstructionClock() (GetSystemClock()/1)
#define GetPeripheralClock() (GetInstructionClock()/1) //
long Baud_Rate;
Baud_Rate = 9600;
TRISFbits.TRISF8 = 0; // Set UART1TX like output
TRISFbits.TRISF2 = 1; // Set UART1RX like input
U1MODE = 0x00008000;
U1STA = 0x00001400; // RXEN set, TXEN set
U1BRG = ((USART_Clock_Source)/(Baud_Rate/16))-1;
May it be a fault on the external oscillator or maybe is there an error on the baud rate calculation? I cannot understand.
Here is an error:
U1BRG = ((USART_Clock_Source)/(Baud_Rate/16))-1;
it should be:
U1BRG = ((USART_Clock_Source)/(Baud_Rate*16))-1;
And this:
#define GetSystemClock() (80000000ul) // Hz
should be
#define GetSystemClock() (8000000ul) // Hz
In this calculation is 8 MHz the instruction frequency not the clock frequency. The instruction frequency is half of the clock.

Raspberry pi - Arduino communication

I've designed a tachometer using an arduino setup and I get the output values(rpm), but since I don't have an wifi module, I've connected my arduino and raspberry pi 4 using usb. I can read the rpm value in the pi terminal. But now I need to send these data to an adafruit io page. How do I write the code to read the data from the usb port of my pi in real-time? I've written a script which can print it on the webpage but each time I've to write a value. It would be really helpful if i can get the answers. I'm new to coding and just exploring these.
from Adafruit_IO import*
ADAFRUIT_IO_USERNAME = '******'
ADAFRUIT_IO_KEY = '**********************'
aio = Client(ADAFRUIT_IO_USERNAME,ADAFRUIT_IO_KEY)
try:
test = aio.feeds('test')
except RequestError:
test_feed = Feed(name='test')
test_feed = aio.create_feed(test_feed)
val = 4
aio.send('test',val)
The below code is an example of what will work in Python, assuming your USB is connected at /dev/tty.usbmodem14201:
import serial
ser = serial.Serial('/dev/tty.usbmodem14201', baudrate=9600) # NB set your baudrate to the one you are using!
ser.flushInput()
while True: #constant loop to get readings in real time
ser_bytes = ser.readline() #read the incoming message
decoded_bytes = ser_bytes[0:len(ser_bytes)-2].decode("utf-8") #decode it
print(decoded_bytes) # print out what you got or, alternatively, make a web call to Adrafruit

I noticed something in the optiboot bootloader hex file for Arduino. Why so?

When I look at the bootloader hex file, the starting address from the word type of the program is 7E00 according to intel-hex format. This is the 3F00. The interesting part starts right now. According to the Atmega328p datasheet, the BOOTS1 and BOOTS2 registers must be set for this to start from 3F00. But when I look at the Arduino Uno fuse settings,
lfuse = 0xff
hfuse = 0xde
efuse = 0x05
is defined as such. In this case . The BOOTS1 and BOOTS2 parameters in the High fuse settings parameter are set as not set.
Is there something I'm missing?
Here is the optibootbootloader.hex file
:107E0000112484B714BE81FFF0D085E080938100F7
:107E100082E08093C00088E18093C10086E0809377
:107E2000C20080E18093C4008EE0C9D0259A86E02C
:107E300020E33CEF91E0309385002093840096BBD3
:107E4000B09BFECF1D9AA8958150A9F7CC24DD24C4
:107E500088248394B5E0AB2EA1E19A2EF3E0BF2EE7
:107E6000A2D0813461F49FD0082FAFD0023811F036
:107E7000013811F484E001C083E08DD089C08234E0
:107E800011F484E103C0853419F485E0A6D080C0E4
:107E9000853579F488D0E82EFF2485D0082F10E0AE
:107EA000102F00270E291F29000F111F8ED06801E7
:107EB0006FC0863521F484E090D080E0DECF843638
:107EC00009F040C070D06FD0082F6DD080E0C81688
:107ED00080E7D80618F4F601B7BEE895C0E0D1E017
:107EE00062D089930C17E1F7F0E0CF16F0E7DF06D8
:107EF00018F0F601B7BEE89568D007B600FCFDCFD4
:107F0000A601A0E0B1E02C9130E011968C91119780
:107F100090E0982F8827822B932B1296FA010C0160
:107F200087BEE89511244E5F5F4FF1E0A038BF0790
:107F300051F7F601A7BEE89507B600FCFDCF97BE46
:107F4000E89526C08437B1F42ED02DD0F82E2BD052
:107F50003CD0F601EF2C8F010F5F1F4F84911BD097
:107F6000EA94F801C1F70894C11CD11CFA94CF0C13
:107F7000D11C0EC0853739F428D08EE10CD085E9AC
:107F80000AD08FE07ACF813511F488E018D01DD067
:107F900080E101D065CF982F8091C00085FFFCCF94
:107FA0009093C60008958091C00087FFFCCF809118
:107FB000C00084FD01C0A8958091C6000895E0E648
:107FC000F0E098E1908380830895EDDF803219F02E
:107FD00088E0F5DFFFCF84E1DECF1F93182FE3DFCA
:107FE0001150E9F7F2DF1F91089580E0E8DFEE27F6
:047FF000FF270994CA
:027FFE00040479
:0400000300007E007B
:00000001FF
You are correct that this high fuse byte of the Arduino Uno is 0xDE; I confirmed that by checking boards.txt.
That means that BOOTSZ is set to 11, which means the bootloader size is 256 words and starts at word 0x3F00 (byte address 0x7E00), as documented in the ATmega328P datasheet (Table 26-7). There is no contradiction.

Nordic nrf51822 and S130 never gets to my application code

I am trying to run a NRF51822 chip using Emblocks and OpenOCD, the debugger interface is a ST-Link from a Discovery board, which supports SWD.
When I program the Blank device everything works fine, the program flow reaches the main function. However, when I flash S130, the program flow never reaches my main function (I don't have any other application code).
I have checked the assembly code and S130 is stuck on a (arm asm incoming) WFE and b.n instruction, to my knowledge, it seems like it is waiting for an interrupt, event or for a wake up to happen before doing anything... is this the expected behaviour or I am doing something wrong?
The only pins I have connected are the SWD lines (2 pins) GND and VDD (3 volts).
I solved it a long time ago, but forgot to post the solution. The problem was the script file provided with Emblocks, it needed to be modified.
I got it working by modifying the sections in the linker file from this:
MEMORY
{
SOFTD (rx) : ORIGIN = 0x00000000, LENGTH = 0x20000
FLASH (rx) : ORIGIN = 0x00020000, LENGTH = 0x20000
RAM (rwx) : ORIGIN = 0x20002800, LENGTH = 0x1800
}
To this:
MEMORY
{
SOFTD (rx) : ORIGIN = 0x00000000, LENGTH = 0x1C000
FLASH (rx) : ORIGIN = 0x0001C000, LENGTH = 0x24000
RAM (rwx) : ORIGIN = 0x20002800, LENGTH = 0x1800
}
Now the program flow reaches main.

Controlling MDrive 23 with Python under Linux

MDrive 23 motor takes commands from a terminal, and I got it to work with screen program:
screen /dev/ttyUSB0
Is this is called a serial terminal? I'm unfamiliar with the details of the connection, but feel like I should be able to use PySerial to send the commands.
I tried:
import serial
ser = serial.Serial('/dev/ttyUSB0', 19200)
ser.isOpen() # Returns True
ser.write('ma 100000\r\n') # Does nothing...
ser.inWaiting() # Returns 0
ser.close()
I didn't know how to set the other init variables, like:
parity = serial.PARITY_ODD,
stopbits = serial.STOPBITS_TWO
bytesize = serial.SEVENBITS
I'm going to try guessing some values next... The documentation is lame, but it mentions MODBUS TCP and Mcode.
How do I set these and are there any syntax errors in my snippet?
I know how to send arguments to the Serial object, but I do not know what values are typical.
The other parameters to the Serial constructor are set in a similar way as port and baudrate:
ser = serial.Serial(port = '/dev/ttyUSB0', baudrate=19200, bytesize=serial.SEVENBITS, parity=serial.PARITY_ODD, stopbits=serial.STOPBITS_TWO)
ser.write('whatever')
ser.flush() # wait for data to be written
ser.close()
Edit: It seems the default settings are 9600 baud, 8 bits, no parity and 1 stop bit. In addition no flow-control is used. That would be equivalent to:
ser = serial.Serial(port = '/dev/ttyUSB0', baudrate=9600, bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, xonxoff=False, rtscts=False, dsrdtr=False)
As all values, except port, are set to their defaults, you may use:
ser = serial.Serial(port = '/dev/ttyUSB0')
The last thing to worry about is which (read) timeout to set. This is measured/set in seconds (float allowed) and sets how long a read() command will block before returning what has been read.

Resources