I2C not working in PIC18F46K22 for DS3231 - pic

I'm using PIC18F46K22 to display the time from DS3231 rtc device via I2C. I'm facing issue while setting the acknowledgement (ACKEN). I'm feeling something wrong in my configuration especially in Pin Configuration and setting the baud rate with SSP1ADD.
I'm using 20MHz and my DS3231 is supports for 400kHz.
While setting the acknowledgement(ACKEN), program getting hang, I mean, it is not able to set it not coming out from the step.
Please help me to fix the issue, please find the attached code.

Related

Uploading to replica Arduino Mega2560 fails

everyone
I could really need some help. I built an ArduinoMega2560, see schematic. I tested the PCB.
I loaded the driver for the Mega16u2 on it. I loaded the Bootloader for the atmega2560-Chip per SCK/MOSI/MISO-Pins successfully. But uploading sketches with the arduino-IDE fails with the error message "timeout". I also ran the loopback test successfully.
I guess i have some wiring problem or forgotten something important.
Maybe one of you knows this very well and can give me a hint. I do not know how to continue.
loopback test
multiple bootloader flashing and 16u2-flashing

Different WiFi modes in arduino for esp32

I've recently started playing with esp32. I was searching for various WiFi.mode() options available for esp32 but I couldn't find it anywhere. Can anyone help point out the source for that information?
Thanks
The code for the ESP32 Arduino SDK WiFi class is located at
https://github.com/espressif/arduino-esp32/tree/master/libraries/WiFi/src
WiFi.h doesn't define a method for mode() but it does inherit from WiFiGeneric.h which does have methods for mode() and getMode(). You can find the code for those methods in WiFiGeneric.cpp.
The mode is represented using type wifi_mode_t, which is defined in WiFiType.h. The available options are WIFI_MODE_OFF, WIFI_MODE_STA, WIFI_MODE_AP, and WIFI_MODE_APSTA.
There is some resonable but partial doc on the Espressif pages: Espressif Wifi doc
This doc explains some of the different wifi modes of the esp32 that can be found in WiFiType.h.
WIFI_MODE_NULL : The null mode or the WIFI_MODE_OFF which is the OFF mode
WIFI_MODE_STA : The Station mode, which is the standard client mode
WIFI_MODE_AP : The Access Point mode where clients can connect to the ESP32
WIFI_MODE_APSTA : The hybrid mode where the ESP connect to an AP as a client and recieve connections from client as an AP.
WIFI_MODE_MAX : The MAX mode has no explaination on what it is supposed to do. But it dose not seems to be implemented anyway.
The WiFi mode types come from an enumerated list. WIFI_MODE_MAX is the last entry in the list (and I guess that's why it's MAX). An odd convention as WIFI_MODE_UNKNOWN or similar would be more intuitive.

How to ensure bootloader is started

I am working with openmote-cc2538 for the project: https://github.com/cetic/6lbr/wiki
Here when I was trying to flash openmote with this command
sudo make TARGET=cc2538dk BOARD=openmote-CC2538 bootload0/dev/ttyUSB0 slip-radio.upload
This error message is displayed
ERROR:Cant CONNECT TO TARGET:Ensure bootloader is started(no answer on sync sequence)
cc2538 bsl.py script is available for uploading binary to openmote. But I don't have much experience about this. Can anybody give me some suggestions regarding how to proceed??
Grab a scope and probe different digital I/O pins on the CC2538. Typically a bootloader will initialize all the ports on the chip and you will see them change state, which is an indication that the bootloader is indeed running. I would guess one of the LEDs would change state as well (which doesn't require a scope).

MCP25625 doesnt send CAN messages

Im using MCP25625 which is MCP2515+integrated MCP2551 and trying to send messages in a loop.
For some reson I dont see any signal at all on CANH, CANL lines.
SPI communication works correctly
I use software reset procedure
There is clear 20Mhz sinewave from Crystal
There is TXCAN signal
At the moment there is nothing at all connected to CANL,CANH, just the probe.
I also tried to run in LOOPBACK mode and it works, but in the NORMAL modethere is nothing coming out.
Seems like transciever is broken? I changed 2 chips already, so it shouldnt be the problem.
Any suggestion guys?
Schematics
have you considered the modes of operation of the CAN transceiver?
In your schematic, the pins value is not clear.
If you have connected it to the MCU, Please pull it to LOW to select the normal operation mode for the transceiver (it is different configuration then the CAN controller settings, hence might cause some confusion!).
Controlling it by MCU is a good choice as it gives more control to prevent network communication from being blocked, due to a CAN controller which is out of control.
Else, connect it to ground to ensure normal operation mode specifically for the build in transceiver.
I have referred the data-sheet's of MCP25625, MCP2515 and TJA1050 to bring out this conclusion.
TJA1050 has pin-S for selecting high-speed mode and silent mode. Both modes are similar to normal mode and standby mode respectively of the transceiver of MCP25625.
Also, pin-S configuration in TJA1050 is similar to pin-STBY configuration in MCP25625.
0(LOW) for high-speed/normal mode of TJA1050/MCP25625-Transceiver
1(HIGH) for silent/standby mode of TJA1050/MCP25625-Transceiver
Hope this helps.
At the moment there is nothing at all connected to CANL,CANH, just the probe.
Hope you have connected the termination resistor? It is on the schematic, but ...

Accessing/monitoring battery status through SMBus

I am currenlty trying to monitor my battery status through SMBus.
I have a battery along with a control board that constantly outputs the battery status.
This control board is then connected to my mother board through a I2C-USB module.
I need to write a program to recognize the SMBus connection and transmit the battery status to the user.
I'm a beginner when it comes to dealing with smart batteries and I2C/SMBus, and I'm somewhat lost with how to approach this problem.
Any help of suggestions would be appreciated. Thanks.
Your question is a bit lacking. What kind of I2C-USB module? Or rather does it come with a Linux driver? If it does you probably won't need to write one. An application will do. You can read more about I2C and SMBus here.
Basically what you need is the I2C address of the control board (a single byte). When you have the address you (as the master) issue read commands over the I2C bus to the control board using its address and reads the response. If there's a driver for the I2C-USB module this should be straightforward enough. Plug in the device and open() the device (/dev/[i2c-usb-name] where [i2c-usb-name] is the name of the device). Then follow the driver implementer's guide how to setup and send data over that device (typically using read()/write() or ioctl()). Here are some additional information on working with I2C from user space: http://www.mjmwired.net/kernel/Documentation/i2c (select topics in the menu on the left hand side).
If you must write the driver yourself, the first stop for a Linux device driver beginner is the LDD3. Read it, it's quite a pleasant read.

Resources