Introduction:
Recently, I stumbled upon a scenario where I had to write Nano130’s SPI driver code for ADE7753 while I already had written this with NUC200. You can go through my previous blog to compare this blog with previous one and you will find out how stuffs change when microcontrollers change.

Note:
As we know Nano130 works on 3.3 volt and ADE7753 works on 5 volt so need a signal voltage translator. Follow this link to know how to use a voltage level translator between two SPI devices.

Pins connection:
See diagram for the pin connections

Source Code:-
Include some header file which is given below

Now need to declare some variables

Need to declare a function to write in the register of ADE7753. Three parameters are needed to call this function.

  1. Address of the register in which you want to write
  2. Data which you want to write to that register
  3. Total no. of bytes in data

See the function

After that make another function to read a register of ADE7753. Two parameters will be needed to call this function

  1. Address of the register to which you want to read
  2. total bytes which you want to read

See the function

Now Time to write main function. In this function we will initialize the system clock, SPI clock and setting of SPI port0.

Initialize UART port 0 to see the output on serial monitor. Always remember that Baud rate of serial monitor and microcontroller should be same.

Write a while(1) loop which is a infinite loop and will write and read registers continue with delay of some seconds.

Note:-

  1. You will receive zero if AC input is not connected to ADE7753 IC so first connect AC input then do testing.
  2. This board comes with the LCD which conflicts with the SPI0 port so it is highly recommended to remove LCD from Nano130 board.

If still you are facing any problem please leave comment.